WI – Install Varnish Cache
WI – Install Varnish Cache
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
dnf noarch 4.0.9.2-1.el7_6 extras 357 k
Installing for dependencies:
deltarpm x86_64 3.6-3.el7 base 82 k
dnf-data noarch 4.0.9.2-1.el7_6 extras 51 k
libcomps x86_64 0.1.8-14.el7 extras 75 k
libdnf x86_64 0.22.5-1.el7_6 extras 533 k
libmodulemd x86_64 1.6.3-1.el7 extras 141 k
librepo x86_64 1.8.1-7.el7 base 81 k
libsolv x86_64 0.6.34-4.el7 base 329 k
python2-dnf noarch 4.0.9.2-1.el7_6 extras 414 k
python2-hawkey x86_64 0.22.5-1.el7_6 extras 68 k
python2-libcomps x86_64 0.1.8-14.el7 extras 47 k
python2-libdnf x86_64 0.22.5-1.el7_6 extras 608 k
Transaction Summary
================================================================================
Install 1 Package (+11 Dependent packages)
Installed:
dnf.noarch 0:4.0.9.2-1.el7_6
Dependency Installed:
deltarpm.x86_64 0:3.6-3.el7 dnf-data.noarch 0:4.0.9.2-1.el7_6
libcomps.x86_64 0:0.1.8-14.el7 libdnf.x86_64 0:0.22.5-1.el7_6
libmodulemd.x86_64 0:1.6.3-1.el7 librepo.x86_64 0:1.8.1-7.el7
libsolv.x86_64 0:0.6.34-4.el7 python2-dnf.noarch 0:4.0.9.2-1.el7_6
python2-hawkey.x86_64 0:0.22.5-1.el7_6 python2-libcomps.x86_64 0:0.1.8-14.el7
python2-libdnf.x86_64 0:0.22.5-1.el7_6
Complete!
Transaction Summary
================================================================================
Is this ok [y/N]: y
Complete!
# curl -s
https://packagecloud.io/install/repositories/varnishcache/varnish65/
script.rpm.sh | sudo bash
Detected operating system as centos/8.
Checking for curl...
Detected curl...
Downloading repository file: https://packagecloud.io/install/repositories/varnishcache/varnish65/
config_file.repo?os=centos&dist=8&source=script
done.
Installing yum-utils...
varnishcache_varnish65-source 223 B/s | 833 B 00:03
Package yum-utils-4.0.12-4.el8_2.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Generating yum cache for varnishcache_varnish65...
Generating yum cache for varnishcache_varnish65-source...
[varnishcache_varnish65-source]
name=varnishcache_varnish65-source
baseurl=https://packagecloud.io/varnishcache/varnish65/el/8/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/varnishcache/varnish65/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
Transaction Summary
================================================================================
Install 2 Packages
Installed:
jemalloc-5.2.1-2.el8.x86_64 varnish-6.5.1-0.0.el8.x86_64
Complete!
Transaction Summary
================================================================================
Install 2 Packages
Installed:
hitch-1.5.2-1.el7.x86_64 libev-4.15-7.el7.x86_64
Complete!
# vi /etc/httpd/conf/httpd.conf
Dari
Listen 80
<VirtualHost *:80>
Menjadi
Listen 8080
<VirtualHost *:8080>
# cd /etc/httpd/conf.d/
# mv ssl.conf /root/ssl.conf.orig
# mv nss.conf nss.conf.orig
# systemctl restart httpd
Menjadi :
ExecStart=/usr/sbin/varnishd -a :80 -a 127.0.0.1:8443,proxy -f /etc/varnish/default.vcl -s malloc,256m
# cd /etc/pki/tls/certs/
# cat STAR_propanraya_com.crt STAR_propanraya_com.ca-bundle STAR_propanraya_com_key.txt >
STAR_propanraya_com.pem
# vi /etc/hitch/hitch.conf
Ubah baris
Dari :
backend = "[127.0.0.1]:6086" # 6086 is the default Varnish PROXY port.
pem-dir = "/etc/pki/tls/private"
Menjadi
backend = "[127.0.0.1]:8443" # 8443 is the default Varnish PROXY port.
#pem-dir = "/etc/pki/tls/private"
Tambahkan baris:
pem-file = "/etc/pki/tls/certs/STAR_propanraya_com.pem"
Jika dibutuhkan SSL multidomain / domain yang lain, misalnya mail.jtklinux.com maka ditambakan baris
seperti dibawah ini :
pem-file = "/etc/pki/tls/certs/STAR_propanraya_com.pem"
pem-file = "/etc/pki/tls/certs/mail-jtklinux-com.pem"
Oct 13 15:02:21 webha2 systemd[1]: Starting Network proxy that terminates TLS/SSL connections...
Oct 13 15:02:21 webha2 hitch[4665]: {core} hitch 1.5.2 starting
Oct 13 15:02:21 webha2 hitch[4665]: {core} Loading certificate pem files (1)
Oct 13 15:02:21 webha2 hitch[4665]: {core} Daemonized as pid 4666.
Oct 13 15:02:21 webha2 hitch[4667]: {core} Process 0 online
Oct 13 15:02:21 webha2 hitch[4668]: {core} Process 1 online
Oct 13 15:02:21 webha2 systemd[1]: Started Network proxy that terminates TLS/SSL connections.
Oct 13 15:02:21 webha2 hitch[4669]: {core} Process 2 online
Oct 13 15:02:21 webha2 hitch[4670]: {core} Process 3 online
Oct 13 15:02:21 webha2 hitch[4666]: {core} hitch 1.5.2 initialization complete
Dibawah
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if (std.port(server.ip) != 443) {
set req.http.location = "https://" + req.http.host + req.url;
return(synth(301));
}
}
sub vcl_synth {
if (resp.status == 301) {
set resp.http.location = req.http.location;
set resp.status = 301;
return (deliver);
}
}
# curl -I http://localhost
HTTP/1.1 301 Moved Permanently
Date: Wed, 14 Oct 2020 08:00:44 GMT
Server: Varnish
X-Varnish: 62
location: https://localhost/
Content-Length: 0
Connection: keep-alive
# curl -I https://devtender.propanraya.com
HTTP/1.1 200 OK
Date: Wed, 14 Oct 2020 07:59:57 GMT
Server: Apache
Last-Modified: Tue, 13 Oct 2020 09:02:59 GMT
ETag: "4a-5b189ae73db46"
Content-Length: 74
Content-Type: text/html; charset=UTF-8
X-Varnish: 59
Age: 0
Via: 1.1 varnish (Varnish/6.5)
Accept-Ranges: bytes
Connection: keep-alive
# nmap localhost
Starting Nmap 6.40 ( http://nmap.org ) at 2020-10-13 15:05 WIB
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000011s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 989 closed ports
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
111/tcp open rpcbind
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
631/tcp open ipp
3306/tcp open mysql
8080/tcp open http-proxy
8443/tcp open https-alt
9000/tcp open cslistener