การจัดการ Server > Haproxy
HAproxy web loadbalance On ubuntu16.04
(1/1)
ผู้ดูแลระบบ:
ติดตั้ง haproxy
sudo apt-get -y install haproxy
ดูversion
haproxy -v
แก้ไข
sudo nano /etc/haproxy/haproxy.cfg
ส่วนท้าย file เพิ่ม
frontend firstbalance
bind 0.0.0.0:80
default_backend webservers
backend webservers
balance roundrobin
cookie SERVERID insert indirect nocache
server s1 192.168.247.148:80 check cookie s1
server s2 192.168.247.149:80 check cookie s2
หมายเหตุ:
การ config แบบนี้ใช้สำหรับ webserver ที่่ใช้ session haproxy แบบนี้จะจ่ายงานให้ web server ตัวใดตัวหนึ่งทำงานอยู่ตัวเดียว สำหรับการเรียกใช้แต่ละครั้ง จะไม่สลับไปมา
และจะสลับ webserver ตัวอื่นทำงานอีกทีก็ต่อเมื่อมีการเรียกใช้งานเว็บ ครั้งใหม่
เสร็จสิ้น รีสตาร์ท haproxy
systemctl restart haproxy
ทดสอบด้วยการพิมพ์ ip เครื่อง haproxy แล้ว refresh
ผู้ดูแลระบบ:
แก้ปัญหาการไม่แสดง ip เครื่อง client โดย
เข้าไปแก้ config haproxy
sudo nano /etc/haproxy/haproxy.cfg
เพิ่มต่อท้ายในชุด defaults
option forwardfor
option http-server-close
ctrl+O เพื่อบันทึก
system restart haproxy เพื่อให้ hp ทำงานใหม่
นำร่อง
[0] ดัชนีข้อความ
Go to full version