【发布时间】:2017-12-05 07:39:17
【问题描述】:
这是我的 haproxy 配置
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 16384
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/run/haproxy.cmd
defaults
mode http
log global
option httplog
option dontlognull
option httpclose
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 20s
timeout client 45s
timeout server 45s
timeout check 20s
maxconn 16384
listen stats :9000
mode http
stats enable
stats uri /haproxy
stats realm HAProxy\ Statistics
stats auth haproxy:password
stats admin if TRUE
listen http :80
#balance leastconn
#balance roundrobin
balance source
option http-server-close
option forwardfor
server web1 10.0.2.10:8080 check inter 3000 rise 2 fall 3
server web2 10.0.2.11:8080 check inter 3000 rise 2 fall 3
# acl has_www hdr_beg(host) -i www
# http-request redirect code 301 location myapp
它是这样工作的:
我输入http://www.example.com:8000 或http://www.example.com,所以它会转到jboss 的8080 端口。
我的应用程序实际上可以通过example.com/suite 访问,但是由于 ISP 阻止了端口 80,这就是我使用端口 8000 的原因,因此;我的应用程序可以通过example.com:8000/mypp访问
我想使用 haproxy 配置将输入 example.com:8000 的人转发到 example.com:8000/myapp
如何实现呢? 我错过了什么对吗?
【问题讨论】:
标签: redirect configuration reverse-proxy haproxy forward