Common Software Installation
1. HAProxy
Install
Install via Docker. 6001 is the admin port, 6000 is the service port.
shell
docker rm -f haproxy
sudo docker run -d --name haproxy \
-v /data/app/haproxy:/usr/local/etc/haproxy:ro \
-p 6001:6001 -p 6000:6000 -p 6043:6043 -p 443:6043 -p 80:80 -p 8080:80 haproxytech/haproxy-alpine:2.4docker rm -f haproxy
sudo docker run -d --name haproxy \
-v /data/app/haproxy:/usr/local/etc/haproxy:ro \
-p 6001:6001 -p 6000:6000 -p 6043:6043 -p 443:6043 -p 80:80 -p 8080:80 haproxytech/haproxy-alpine:2.4Config File
File path: /data/app/haproxy/haproxy.cfg
yml
global
stats socket /var/run/api.sock user haproxy group haproxy mode 660 level admin expose-fd listeners
log stdout format raw local0 info
defaults
mode http
timeout client 120s
timeout connect 120s
timeout server 120s
timeout http-request 120s
log global
frontend stats
bind *:6001
stats enable
stats uri /
stats auth username:your-password
stats refresh 10s
frontend myfrontend
bind :6000
default_backend webservers
http-response set-header Access-Control-Allow-Origin *
http-response set-header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
http-response set-header Access-Control-Allow-Headers "Content-Type, Authorization"
backend webservers
mode http
cookie SERVER-COOKIE insert indirect nocache
option httpchk GET /api/status HTTP/1.1\r\nHost:\ aidutu.cn
server s5001 172.17.0.1:5001 cookie s5001 check
server s5002 172.17.0.1:5002 cookie s5002 check
server s5003 172.17.0.1:5003 cookie s5003 check
server s5004 172.17.0.1:5004 cookie s5004 checkglobal
stats socket /var/run/api.sock user haproxy group haproxy mode 660 level admin expose-fd listeners
log stdout format raw local0 info
defaults
mode http
timeout client 120s
timeout connect 120s
timeout server 120s
timeout http-request 120s
log global
frontend stats
bind *:6001
stats enable
stats uri /
stats auth username:your-password
stats refresh 10s
frontend myfrontend
bind :6000
default_backend webservers
http-response set-header Access-Control-Allow-Origin *
http-response set-header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
http-response set-header Access-Control-Allow-Headers "Content-Type, Authorization"
backend webservers
mode http
cookie SERVER-COOKIE insert indirect nocache
option httpchk GET /api/status HTTP/1.1\r\nHost:\ aidutu.cn
server s5001 172.17.0.1:5001 cookie s5001 check
server s5002 172.17.0.1:5002 cookie s5002 check
server s5003 172.17.0.1:5003 cookie s5003 check
server s5004 172.17.0.1:5004 cookie s5004 checkPort Forwarding
Forward 6043/443 to port 443 on a new IP, and 80 to port 80:
yml
frontend sh2gz
bind *:6043,*:443
mode tcp
default_backend gz443
frontend sh2gz80
bind *:80
mode tcp
default_backend gz80
backend gz443
mode tcp
server gz <target-ip>:443
backend gz80
mode tcp
server gz80 <target-ip>:80frontend sh2gz
bind *:6043,*:443
mode tcp
default_backend gz443
frontend sh2gz80
bind *:80
mode tcp
default_backend gz80
backend gz443
mode tcp
server gz <target-ip>:443
backend gz80
mode tcp
server gz80 <target-ip>:80
HIGO