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

Zabbbix Graph Export to PDF

Masih lanjutan dari postingan sebelumnya Instalasi zabbix dan integrasi dengan telegram, karena zabbix belum ada tools resmi untuk export ke pdf, ada beberapa orang yang mencoba membuat tool ini. Nah kali ini kita akan mencobanya.

Mulai ya….

  1. Download https://github.com/martinm76/zabbix-pdf-report/archive/master.zip
wget https://github.com/martinm76/zabbix-pdf-report/archive/master.zip
  1. Extrack hasil download /var/www/html, ubah direktori hasil extract tadi menjadi lebih mudah, apabila tida dirubah juga tidak masalah
cp master.zip /var/www/html
unzip master.zip
mv zabbix-pdf-report-master zabbix-pdf-report
  1. Copy config.inc.php.dist ke config.inc.php.dist, dan edit sesuai dengan zabbix monitoring server (IP zabbix monitoring, user dan password, dan timezone
cp config.inc.php.dist config.inc.php
nano config.inc.php
…
$z_server       = 'http://172.30.0.51/zabbix/'; // Replace YourServerHere with $
$z_user         = 'Admin';
$z_pass         = 'adr12345';
…
$timezone       = 'Asia/Jakarta';
  1. Buat directory reports dan tmp, untuk menampung hasil export pdf. Dan ubah hak akses user ke librenms
mkdir reports
chown -R librenms:librenms reports
mkdir tmp
chown -R librenms:librenms tmp
  1. Buka browser ‘http://172.30.0.51/ zabbix-pdf-report, masukan user dan password 
  2. Pilih host atau hostgroup dan graph yang akan export ke pdf graphnya, untuk export semua graph pada host atau hostgroup bisa menggunakan parameter (#.*#) . Kemudian klik generate 
  3. Hasil generate pdf graphnya