问题
I am completely new to haproxy setup. I want to setup haproxy on top of tomcat servers.
The below configuration works well for tomcat applications.
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 20000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen webfarm 100.100.100.100:80
mode http
stats enable
stats uri /haproxy?statis
stats realm Haproxy\ Auth
stats auth user:password
balance leastconn
cookie JSESSIONID insert indirect nocache
option httpclose
option forwardfor
server web01 192.168.1.1:8080 cookie A check
server web02 192.168.1.2:8080 cookie B check
But i dont want user to enter the complete url. so when a user hits web1.example.com it need to server application from a tomcat webapp directory. Also i dont want the url changed.
Example : http://web1.example.com -> http://192.168.1.1:8080/applications/web1 & http://192.168.1.2:8080/applications/web1
Is this possible with a url redirection and url rewriting? If yes please help me with a sample configuration.
Any help will be really appreciated.
Thanks
回答1:
This is ugly, you should not do that, it causes all sort of issues with redirects, referrers and base URLs for static objects. It's trivial to do with reqrep (to rewrite the request) and rsprep (to rewrite the location), but you'd better switch to a more clever idea than break your site on purpose and then complain all the time that you constantly have broken links in the HTML code etc... In short, don't do this!
来源:https://stackoverflow.com/questions/14013098/haproxy-url-redirection-rewriting