Reverse Proxy Apache

Hi…

Kali ini kita akan coba reverse proxy pada apache2. Lab kali ini didasari dari tugas kantor (hahaha… lagi-lagi karena dapet tugas kantor).

Jadi dikantor sudah ada banyak web server, dengan IP berbeda-beda. Dan beberapa akan mempunyai subdomain yang dapat diakses dari internal kantor maupun dari public.

Topologinya kurang lebih seperti ini, masih menggunakan IP private. Nanti silahkan coba sendiri apabila ingin pasang IP PublicDNS server jadi satu dengan Router dimana menggunakan Mikrotik, dan sudah pernah dibahas disini.

Instalasi dan Seting Front Web Server

Update dan upgrade repository

[email protected]:/home/ubuntu#apt update && apt upgrade –y

Install apache2 dan build essential

[email protected]:/home/ubuntu#apt install build-essential apache2

Enable mod proxy untuk apache2

[email protected]:/home/ubuntu#a2enmod proxy proxy_http proxy_html

Set reverse proxy sub domain a.test.konfigurasi

Copy default.conf ke a.conf

[email protected]:/home/ubuntu#cd /etc/apache2/sites-available/
[email protected]:/etc/apache2/sites-available#cp 000-default.conf cacti.conf

Edit a.conf, sesuaikan dengan nama subdomain dan ip webserver

[email protected]:/etc/apache2/sites-available# nano a.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName a.test.konfigurasi

ServerAdmin [email protected]
#DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

ProxyPreserveHost On
# Servers to proxy the connection, or
# List of application servers Usage
ProxyPass / http://192.168.192.2:80/
ProxyPassReverse / http://192.168.192.2:80/

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Ulangi langkah copy dan edit a.conf untuk b.conf dan c.conf, tentunya disesuaikan dengan nama subdomain dan IP masing-masing.

Selanjutnya, enable a.conf, b.conf dan c.conf

[email protected]:/etc/apache2/sites-available# a2ensite a.conf
Enabling site a.
To activate the new configuration, you need to run:
service apache2 reload


[email protected]:/etc/apache2/sites-available# a2ensite b.conf
Enabling site b.
To activate the new configuration, you need to run:
service apache2 reload


[email protected]:/etc/apache2/sites-available# a2ensite c.conf
Enabling site c.
To activate the new configuration, you need to run:
service apache2 reload

Selanjutnya restart service apache

[email protected]:/etc/apache2/sites-available# service apache2 reload

Menambahkan subdomain pada Router/DNS Server

Setelah front dan backend web sudah siap, sekarang akan menambahkan atau pointing IP front web server ke masing-masing sub domain di Router MikroTik

 Test ping dulu

C:\Users\konfigurasi.net>ping a.test.konfigurasi

Pinging a.test.konfigurasi [172.30.0.58] with 32 bytes of data:
Reply from 172.30.0.58: bytes=32 time=13ms TTL=64
Reply from 172.30.0.58: bytes=32 time=2ms TTL=64
Reply from 172.30.0.58: bytes=32 time=1ms TTL=64
Reply from 172.30.0.58: bytes=32 time=4ms TTL=64

Ping statistics for 172.30.0.58:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 13ms, Average = 5ms

C:\Users\konfigurasi.net>ping b.test.konfigurasi

Pinging b.test.konfigurasi [172.30.0.58] with 32 bytes of data:
Reply from 172.30.0.58: bytes=32 time=1ms TTL=64
Reply from 172.30.0.58: bytes=32 time=2ms TTL=64
Reply from 172.30.0.58: bytes=32 time=2ms TTL=64
Reply from 172.30.0.58: bytes=32 time=6ms TTL=64

Ping statistics for 172.30.0.58:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 6ms, Average = 2ms

C:\Users\konfigurasi.net>ping c.test.konfigurasi

Pinging c.test.konfigurasi [172.30.0.58] with 32 bytes of data:
Reply from 172.30.0.58: bytes=32 time=2ms TTL=64
Reply from 172.30.0.58: bytes=32 time=2ms TTL=64
Reply from 172.30.0.58: bytes=32 time=4ms TTL=64
Reply from 172.30.0.58: bytes=32 time=2ms TTL=64

Ping statistics for 172.30.0.58:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 4ms, Average = 2ms

Sekarang coba buka di web browser

Menghapus local-lvm dan menggunakan seluruh disk untuk root pada Proxmox VE

Hi…

Kali ini saya akan mencoba untuk menghapus local-lvm yang ada pada proxmox dan menggunakan seluruh disk untuk root.

Hal ini bermula dari request dari teman, karena local-lvm pada proxmox tidak bisa digunakan untuk menyimpan iso, backup dan template. Hanya bisa menyimpan disk dari VM atau container.

Setiap kali install proxmox, secara default maka storage akan dibuat menjadi 2, yaitu local dan local-lvm

Langsung saja ya…

Cek dulu seluruh disk dari Command line

[email protected]:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 395M 5.6M 389M 2% /run
/dev/mapper/pve-root 25G 1.4G 22G 6% /
tmpfs 2.0G 43M 1.9G 3% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/fuse 30M 16K 30M 1% /etc/pve
tmpfs 395M 0 395M 0% /run/user/0

[email protected]:~# fdisk -l
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 77106504-0400-4CFA-9B8E-39FED25E3BDF

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 528383 524288 256M EFI System
/dev/sda3 528384 209715166 209186783 99.8G Linux LVM

Disk /dev/mapper/pve-swap: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/pve-root: 24.8 GiB, 26575110144 bytes, 51904512 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Cek LVM yang ada, ada 3 yaitu swap, root dan data. Root untuk system/local storage dan Data untuk Local-lvm

[email protected]:~# lvdisplay
--- Logical volume ---
LV Path /dev/pve/swap
LV Name swap
VG Name pve
LV UUID XF0s3T-bAx6-19Jo-mCXD-uMDy-mtJU-5vYewD
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/pve/root
LV Name root
VG Name pve
LV UUID gNxUs3-gd9K-DLSS-bgAh-ng0K-ZHtX-zjXxTz
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Status available
# open 1
LV Size 24.75 GiB
Current LE 6336
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

--- Logical volume ---
LV Name data
VG Name pve
LV UUID bjS0kv-Jtw0-8RjY-yJ5K-27Zh-WzjC-9gkaZd
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Pool metadata data_tmeta
LV Pool data data_tdata
LV Status available
# open 0
LV Size 56.62 GiB
Allocated pool data 0.00%
Allocated metadata 0.03%
Current LE 14495
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4

Pertama hapus storage local-lvm dari dashboard Proxmox

Setelah hapus dari dashboard, hapus lvm data melalui CLI

[email protected]:~# lvremove /dev/pve/data
Do you really want to remove and DISCARD active logical volume pve/data? [y/n]: y
Logical volume "data" successfully removed

Kemudian, resize lvm root untuk dapat menggunakan seluruh kapasitas disk

[email protected]:~# lvresize /dev/pve/root /dev/sda3
Size of logical volume pve/root changed from 24.75 GiB (6336 extents) to 95.75 GiB (24511 extents).
Logical volume pve/root successfully resized.

Selanjutnya cek lvm yang ada, setelah hapus lvm data dan resize root

[email protected]:~# lvdisplay
--- Logical volume ---
LV Path /dev/pve/swap
LV Name swap
VG Name pve
LV UUID XF0s3T-bAx6-19Jo-mCXD-uMDy-mtJU-5vYewD
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Status available
# open 2
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/pve/root
LV Name root
VG Name pve
LV UUID gNxUs3-gd9K-DLSS-bgAh-ng0K-ZHtX-zjXxTz
LV Write Access read/write
LV Creation host, time proxmox, 2018-12-28 14:04:27 +0700
LV Status available
# open 1
LV Size 95.75 GiB
Current LE 24511
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

LVM root sudah bertambah kapasitasnya, selanjutnya resize storage local

[email protected]:~# resize2fs /dev/mapper/pve-root
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/mapper/pve-root is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 12
The filesystem on /dev/mapper/pve-root is now 25099264 (4k) blocks long.

Cek kapasitas storage local dari CLI dan dashboard

[email protected]:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 395M 5.6M 389M 2% /run
/dev/mapper/pve-root 95G 1.4G 89G 2% /
tmpfs 2.0G 43M 1.9G 3% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/fuse 30M 16K 30M 1% /etc/pve
tmpfs 395M 0 395M 0% /run/user/0