I currently am using haproxy to do reverse_proxy on my end.
Unfortunately, I cannot get it to work!.
This is my config:
backend twisted
mode http
timeout connect 10s
timeout server 30s
balance roundrobin
server apache1 127.0.0.1:11111 weight 1 maxconn 512
backend cometd
mode http
timeout connect 5s
timeout server 5m
balance roundrobin
server cometd1 127.0.0.1:12345 weight 1 maxconn 10000
frontend http_proxy #arbitrary name for the frontend
bind *:80 #all interfaces at port 80
mode http
option forwardfor
option http-server-close
option http-pretend-keepalive
default_backend twisted #by default forward the requests to apache
acl req_cometd_path path_beg /comet/
use_backend cometd if req_cometd_path
acl req_cometd_host hdr_dom(host) -i comet.okiez.com
use_backend cometd if req_cometd_host
- If I try to access
localhost/comet/test1/test2, haproxy
forwards to the cometd backend
correctly. However, the request path
remains to be /comet/test1/test2,
where my comet engine (orbited)
doesn't handle the /comet/ part. Is
there anyway to tell haproxy to drop
the first /comet/ in the requests
that gets directed to the cometd
backend? - As you can see, I have acl req_cometd_host hdr_dom(host) -i comet.okiez.com too. This simply stopped working. I don't know if accessing http://comet.localhost/test1/test2 or comet.127.0.0.1/test1/test2 makes any sense at all. How can I write acl req_cometd_host hdr_dom(host) -i to for localhost addresses?
Best Answer
Put the
into your backend definition. That way, Haproxy can use that path for its routing decision in the frontend. Here, a request with
/comet
at the beginning will match thereq_cometd_path
acl and will thus be routed to the correct backend.In the backend itself, you can now adjust the request to be suitable for the actual application server behind it. Thus the stated rule above is going to remove the
/comet
from the beginning of the path for all requests going through the comet backend.Edited (added the following):
Regarding your second issue,
hdr_dom
only matches if the stated string (in your case comet.okiez.com) is found isolated or delimited by dots in the header. You probably want to use one ofFor more details, have a look at the Haproxy configuration manual.