0

I have serverA with haproxy and configuration:

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

Now, i goes to http://serverA/admin?stats and got statistic. On servers serverB and serverC installed WebSphere Application Server and WebSphere Portal Server (WAS it is like Tomcat and WPS it is like any application deployed to Tomcat). It hosts on port 100039. Now i goes to http://serverA/wps/portal and got my portal, but when i click on any link to any page, i got redirect to http://serverA:100039/wps/portal/bla/bla, this happens because WPS response with its port - 100039, but my haproxy configuration listen only 80 port. What i've tried:

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

For an example, in nginx i got like this:

My application hosts on 3000 port and usefull part of my nginx configuration looks like this:

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
}

How i can do this in HAProxy?

dikkini
  • 1,184
  • 1
  • 23
  • 52

2 Answers2

0

This question is similar to WebSphere Portal behind reverse proxy and getServerPort()

I think the issue is that WebSphere Application Server (traditional) doesn't honor host headers properly, which can impact getting reverse proxies to work.

Try the settings recommended in that other answer (adjust the apache configuration setting for haproxy), and all should be well.

Community
  • 1
  • 1
ebullient
  • 1,250
  • 7
  • 16
0

In your backend section, use "http-request set-header" to set $WSSP and $WSSN to your client-visible hostname and port. They will then be used for self-referential redirects.

Or, set the websphere custom properties trusthostheaderport and com.ibm.ws.webcontainer.extractHostHeaderPort (http://www-01.ibm.com/support/docview.wss?uid=swg21569667) to respect the port in the Host: header.

With this option you may need to ask HAProxy to set the host header to the clients view with "http-request set-header Host" also in the backend section. I'm not sure what the default is.

covener
  • 17,402
  • 2
  • 31
  • 45