Ich habe serverA mit haproxy und Konfiguration:HAProxy Anwendungsserverantwort andere Port
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
Nun, ich gehe an http://serverA/admin?stats und bekam Statistik. Auf den Servern serverB und serverC installierte WebSphere Application Server und WebSphere Portal Server (WAS ist wie Tomcat und WPS und ist wie jede Tomcat-Anwendung). Es hostet auf Port 100039. Jetzt gehe ich zu http://serverA/wps/portal und habe mein Portal, aber wenn ich auf einen Link zu einer beliebigen Seite klicken, habe ich umgeleitet auf http://serverA:100039/wps/portal/bla/bla, geschieht dies, weil WPS-Antwort mit seinem Port - 100039, aber meine Haproxy-Konfiguration nur zuhören 80 Häfen. Was ich versucht habe:
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
Ein Beispiel in nginx ich so bekam:
Meine Anwendung Hosts auf 3000 Port und nützlichem Teil meiner nginx Konfiguration sieht wie folgt aus:
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
}
Wie kann ich das in HAProxy tun?