HAProxy 应用程序服务器响应其他端口



我有带有haproxy和配置的服务器A:

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(WAS 它就像 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.1rnHost: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 中做到这一点?

这个问题类似于反向代理和getServerPort()后面的WebSphere Portal

我认为问题是 WebSphere Application Server(传统)没有正确遵循主机标头,这可能会影响反向代理的工作。

尝试其他答案中推荐的设置(调整 haproxy 的 apache 配置设置),一切都应该很好。

在后端部分中,使用"http-request set-header"将$WSSP$WSSN设置为客户端可见的主机名和端口。然后,它们将用于自我引用重定向。

或者,将 Websphere 定制属性设置为 trusthostheaderportcom.ibm.ws.webcontainer.extractHostHeaderPort (http://www-01.ibm.com/support/docview.wss?uid=swg21569667) 以遵循 Host: 标头中的端口。

使用此选项,您可能需要要求 HAProxy 将主机标头设置为客户端视图,并在后端部分使用"http-request set-header Host"。 我不确定默认值是什么。

最新更新