Install Apache Proxy di Ubuntu 16.04

Informasi Lain

Install apache

sudo apt install apache2 apache2-utils sysv-rc-conf

Aktifkan module Apache berikut

sudo a2enmod access_compat auth_basic authn_core authn_file authz_core authz_groupfile authz_host proxy proxy_http proxy_connect cache cache_disk

Edit Konfigurasi Port Apache

sudo vi /etc/apache2/ports.conf

Edit pada bagian listen

Listen 3128

Edit Konfigurasi Apache untuk Cache :

sudo vi /etc/apache2/mods-available/cache_disk.conf

Beri tanda pagar untuk konfigurasi sebelumnya dan masukkan konfigurasi Berikut sebelum bagian

##################################################################
################# Konfigurasi Cache ESET #######################

#
# Enable HTTP Cache
#
CacheEnable disk http://
CacheDirLevels 4
CacheDirLength 2
CacheDefaultExpire 3600
CacheMaxFileSize 200000000
CacheMaxExpire 604800
CacheQuickHandler Off
CacheRoot /var/cache/apache2/mod_cache_disk

################### End Of Configuration #########################
##################################################################

Edit Konfigurasi Apache Proxy

sudo vi /etc/apache2/mods-available/proxy.conf

Masukkan Konfigurasi Berikut sebelum bagian

##################################################################
############### Konfigurasi HTTP Proxy ESET ####################

#ProxyRemote * http://user_proxy:password_proxy@IPSERVERPROXY:3128

ProxyRequests On
ProxyVia On

SetEnv proxy-initial-not-pooled 1

ErrorLog "|/usr/bin/rotatelogs -n 10 /var/log/apache2/error_log 1M"

Deny from all

#*.eset.com:

Allow from all

#*.eset.eu:

Allow from all

#Antispam module (ESET Mail Security only):

Allow from all

#Services (activation)

Allow from all

#ESET servers accessed directly via IP address:

Allow from all

################### End Of Configuration #########################
##################################################################

Restart apache service:

sudo service apache2 restart

Edit Konfigurasi htcacheclean Apache

sudo vi /etc/default/apache-htcacheclean

Edit size dan interval htcacheclean

HTCACHECLEAN_SIZE=10000M
HTCACHECLEAN_DAEMON_INTERVAL=60
HTCACHECLEAN_PATH=/var/cache/apache2/mod_cache_disk

Test proxy

wget www.google.com -e use_proxy=yes -e http_proxy=IP_ERA_SERVER:3128

Jika Error

-- http://www.google.com/

=> 'index.html'

Connecting to YourDearERAServer:3128... connected.

Proxy request sent, awaiting response... 403 Forbidden

15:05:34 ERROR 403: Forbidden.

maka proxy telah jalan
Jalankan Perintah berikut

echo /usr/bin/htcacheclean -d 60 -i -p /var/cache/apache2/mod_cache_disk -l 10000000000 >> http-forward-proxy.sh

sudo cp http-forward-proxy.sh /root/

sudo chmod +x /root/http-forward-proxy.sh

sudo bash /root/http-forward-proxy.sh

Masukkan ke crontab

sudo crontab -e

Ketik perintah berikut

@reboot bash /root/http-forward-proxy.sh

Disable Service htcacheclean

sudo sysv-rc-conf apache-htcacheclean off

Check yang telah di cache Apache Proxy jika sudah berjalan

sudo htcacheclean -a -p /var/cache/apache2/mod_cache_disk