HAProxy的应用服务器响应其它端口
我serverA的与HAProxy的和配置:HAProxy的应用服务器响应其它端口
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
frontend http-in
bind *:80
default_backend servers
backend servers
option httpchk OPTIONS/
option forwardfor
stats enable
stats refresh 10s
stats hide-version
stats scope .
stats uri /admin?stats
stats realm Haproxy\ Statistics
stats auth admin:pass
cookie JSESSIONID prefix
server tomcat1 serverB:10039 cookie JSESSIONID_SERVER_1
server tomcat2 serverC:10039 cookie JSESSIONID_SERVER_2
现在,我去http://serverA/admin?stats,得到了统计。在服务器serverB和serverC上安装了WebSphere Application Server和WebSphere Portal Server(它与Tomcat和WPS类似,就像任何部署到Tomcat的应用程序一样)。它主机在端口100039.现在我去http://serverA/wps/portal并得到我的门户网站,但是当我点击任何页面的任何链接,我得到重定向到http://serverA:100039/wps/portal/bla/bla,这是因为WPS响应其端口 - 100039,但我的haproxy配置只听80端口。我已经试过:
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD/HTTP/1.1\r\nHost:localhost
举一个例子,在nginx的我得到这样的:在3000端口和我的nginx的配置的一部分有用
我的应用程序的主机看起来是这样的:
location @ruby {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 300;
proxy_pass http://app; #upstream app
}
我如何在HAProxy中做到这一点?
这个问题类似于WebSphere Portal behind reverse proxy and getServerPort()
我认为这个问题是在WebSphere Application Server(传统)不接受主机头得当,这会影响越来越反向代理工作。
尝试在其他答案中推荐的设置(调整haproxy的apache配置设置),并且一切都会好的。
在你的后端部分,使用“http请求设置页眉”设置$ WSSP和$ WSSN你的客户可视主机名和端口。然后它们将被用于自引用重定向。
或者,将websphere自定义属性trusthostheaderport
和com.ibm.ws.webcontainer.extractHostHeaderPort
(http://www-01.ibm.com/support/docview.wss?uid=swg21569667)设置为尊重Host:头中的端口。
使用此选项,您可能需要在HBAroxy的后端部分中使用“http-request set-header Host”将主机头设置为客户端视图。我不确定默认是什么。