ข่าว:

บางหมวดหมู่ทำไว้สำหรับสมาชิกบอร์ด AMSS++&SMSS&PMSS&RMSS โดยเฉพาะนะครับ ทั่วไปไม่เห็น ดังนั้นสมัครเป็นสมาชิกบอร์ดไว้ครับ

Main Menu

ทำ Proxy Server ด้วย varnish (เร็วกว่า Squid)

เริ่มโดย ไท อุบล, 12 กรกฎาคม 2017, :21:45:28 หลังเที่ยง

หัวข้อก่อนหน้า - หัวข้อถัดไป

ไท อุบล

ทำ Proxy Server ด้วย varnish (เร็วกว่า Squid)
here: here: here:


here: here: here:
ตัวอย่างนี้เป็นการติดตั้ง Varnish on Ubuntu Server 16.04
ก่อนอื่น login ด้วยสิทธิ์ root
อัพเดท server
sudo apt-get update

ติดตั้งvarnish
sudo apt-get install varnish -y


ติดตั้งเสร็จแก้ไขค่าคอนฟิก
nano /etc/default/varnish
แก้ port จาก
DAEMON_OPTS="-a :6081 \
เป็น
DAEMON_OPTS="-a :80 \

แก้ Varnish VCL configuration
nano /etc/varnish/default.vcl
เป็น

backend default {
.host = "127.0.0.1";
.port = "8080";
}

แก้ port หากใช้ Apache Virtualhost
nano /etc/apache2/sites-enabled/000-default.conf

จาก
<VirtualHost *:80>

เป็น

<VirtualHost *:8080>

Restart Apache and Varnish
systemctl restart apache2.service
systemctl restart varnish.service

เช็กการทำงาน check the process
ps aux | grep vcache
---------------------------------------
vcache 15569 0.0 0.7 125044 7816 ? Ss 08:20 0:00 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
vcache 15581 0.0 9.3 272012 94900 ? Sl 08:20 0:00 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
--------------------------------------

แก้ port arnish.service
nano /lib/systemd/system/varnish.service

จาก
[...]
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
[...]

เป็น
[...]
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
[...]

Reload and restart Apache and Varnish

systemctl daemon-reload
systemctl restart apache2.service
systemctl restart varnish.service

เช็กการทำงาน
varnishstat

เช็กการทำงานออนเว็บ
curl -I http://your_ip
---------------------------------------
HTTP/1.1 200 OK
Date: Wed, 22 Jun 2016 08:32:03 GMT
Server: Apache/2.4.18 (Ubuntu)
Last-Modified: Wed, 22 Jun 2016 08:18:20 GMT
Vary: Accept-Encoding
Content-Type: text/html
X-Varnish: 32771
Age: 0
Via: 1.1 varnish-v4
ETag: W/"2c39-535d9949460b3-gzip"
Accept-Ranges: bytes
Connection: keep-alive
----------------------------

แสดงว่าการทำงานถูกต้อง End
วันนี้คุณยิ้มให้ใครหรือยัง