一条命令用docker 运行haproxy反代端口

docker run -d –name my-ha -p 8015:8888 -v /home/haproxy:/usr/local/etc/haproxy:ro haproxy:1.7

把haproxy.cfg配置文件放到/home/haproxy下

haproxy.cfg参考:

# Simple configuration for an HTTP proxy listening on port 80 on all     
# interfaces and forwarding requests to a single backend "servers" with a # single server "server1" listening on 127.0.0.1:8000
global
daemon maxconn 256
defaults mode http

timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms

frontend http-in
bind *:80
default_backend servers

backend servers
server server1 127.0.0.1:8000 maxconn 32