Install Squid3.5 di debian 8 untuk transpernt HTTPS


Kali ini akan mem built squid 3.5.27 dari debian source
langsung saja login root

Tambah kan repo debian stretch / 9
/etc/apt/sources.list.d/debian-9-stretch.list
deb http://kartolo.sby.datautama.net.id/debian/ stretch main
deb-src http://kartolo.sby.datautama.net.id/debian/ stretch main

Tambahkan preference nya
/etc/apt/preferences.d/debian-9-stretch.pref
Package: squid3 libecap3
Pin: release n=stretch
Pin-Priority: 550

Package: *
Pin: release n=jessie
Pin-Priority: 500

Package: *
Pin: release n=stretch
Pin-Priority: -1

# apt update
# apt-cache policy squid3
# apt-cache policy libecap3

# apt-get install devscripts quilt
# apt-get build-dep libecap3

Built libecap3 deb
# mkdir ./newlibecap3
# cd newlibecap3
# apt-get source libecap3
# cd libecap-1.0.1

# export QUILT_PATCHES=debian/patches
# while quilt push; do quilt refresh; done

# debuild -us -uc
#cd ..
# sudo dpkg -i libecap3_1.0.1-3.2_amd64.deb libecap3-dev_1.0.1-3.2_amd64.deb

kalau eror bisa install dunlut dari sini
kalau msh tidak bisa install libcap di force install ignore dependencies nya
#dpkg -i --ignore-depends=i libecap3_1.0.1-3.2_amd64.deb,libecap3-dev_1.0.1-3.2_amd64.deb
atau bisacoba
# dpkg --force-all -i package.deb

Built squid deb
# mkdir ./newsquid3
# cd newsquid3
# apt-get source squid3
# wget http://www.squid-cache.org/Versions/v3/3.5/squid-3.5.27.tar.gz

# cd squid3-3.5.{versilama}
# uupdate -v 3.5.27 ../squid-3.5.27.tar.gz

# cd newsquid3/squid3-3.5.26

# cat debian/control | grep Build-Depends

edit debian/control rubah "debhelper (>=10)" menjadi "debhelper " saja

# export QUILT_PATCHES=debian/patches
# while quilt push; do quilt refresh; done
# export DEB_DH_SHLIBDEPS_ARGS_ALL=--dpkg-shlibdeps-params=--ignore-missing-info
# nano debian/rules

tambah kan DEB_CONFIGURE_EXTRA_FLAGS di debian/rules
--enable-ssl \
--enable-ssl-crtd \
--with-openssl \
--enable-linux-netfilter

#debuild -us -uc -nc
biasa nya klo terjadi error ada dependencies package yang di butuhkan belum teristall
kalau sudah sukses mari install
# cd..
# dpkg -i *.deb

pastikan ssl database ter update
#/usr/lib/squid3/ssl_crtd -c -s /var/lib/ssl_db
#chown -R proxy:proxy /var/lib/ssl_db/

Check squid
#squid -v

Generate key dan CA
# openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -keyout /etc/squid/ssl/keyCA.pem -out /etc/squid/ssl/keyCA.pem

#openssl x509 -in /etc/squid/ssl/keyCA.pem -outform DER -out /etc/squid/ssl/CA.der




squid.conf

#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8    # RFC1918 possible internal network
acl localnet src 172.16.0.0/12    # RFC1918 possible internal network
acl localnet src 192.168.0.0/16    # RFC1918 possible internal network
#acl localnet src fc00::/7       # RFC 4193 local private network range
#acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80        # http
acl Safe_ports port 21        # ftp
acl Safe_ports port 443        # https
acl Safe_ports port 70        # gopher
acl Safe_ports port 210        # wais
acl Safe_ports port 1025-65535    # unregistered ports
acl Safe_ports port 280        # http-mgmt
acl Safe_ports port 488        # gss-http
acl Safe_ports port 591        # filemaker
acl Safe_ports port 777        # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3128 intercept
https_port 3127 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/keyCA.pem
acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump bump all
sslproxy_cert_error allow all
sslproxy_flags DONT_VERIFY_PEER
sslproxy_cafile /etc/squid/ssl_cert/CA.der

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /cache 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/cache/squid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:        1440    20%    10080
refresh_pattern ^gopher:    1440    0%    1440
refresh_pattern -i (/cgi-bin/|\?) 0    0%    0
refresh_pattern .        0    20%    4320

Check konfigurasi
#squid -k reconfigure

Untuk transparent tambahkan opsi intercept di http_port

# iptables -t nat -A PREROUTING -i eth0 -p tcp —dport 80 -j REDIRECT —to-ports 3128
# iptables -t nat -A PREROUTING -i eth0 -p tcp —dport 443 -j REDIRECT —to-ports 3127

arahkan gateway client ke ip proxy
ip mikrotik 10.10.1.1
ip proxy 10.10.1.200
ip client 10.10.1.0/24

bisa tambahkan MASQUERADE, di sini hanya memakai 1 eternet

#iptables -t nat -A POSTROUTING -s 10.10.1.0/24 -o eth0 -j MASQUERADE

Untuk transparent di gateway mikrotik tambahkan mangle mark connect dan mark routing yang inti nya mikrotik akan merubah gateway client ke proxy hanya port 80 dan 443 jadi client gateway tetap ke mikrotik berikut magle nya

/ip firewall mangle
add action=mark-connection chain=prerouting comment="re routing http+https " dst-port=80,443 new-connection-mark=mark_proxy protocol=tcp src-address=10.10.1.0/24
add action=mark-routing chain=prerouting connection-mark=mark_proxy new-routing-mark=route_proxy passthrough=no
/ip route
add distance=1 gateway=10.10.1.200 routing-mark=route_proxy

cuma dengan transparent di gateway mikrotik ini ssl handshake agak lama blm tau kenapa belum sempat ngopek lagi

jangan lupa pastikan Import Certificate CA squid proxy ke browser dan os client

ini hasil built nya berjalan normal di sistem saya bisa dunlut disini

Salam
semoga bermanfaat

Komentar

Postingan populer dari blog ini

Cloudflared argo tunnel zero trust service on Mikrotik

Migrasi zimbra ke zimbra dengan rsync

Squid Proxy ssl bump untuk transparent HTTPS #2