I'm trying to use HAProxy to load balance between backend servers, but for some reason the port of the backend server keeps getting inserted.
Example: I connect to 192.168.1.1 (over port 80, since I'm trying to load a webpage from chrome). HAProxy works and I get served a webpage by one of the backends
I then try to click a link inside the page. The link address is still 192.168.1.1 (no port), but when I click it my URL then becomes 192.168.1.1:8000/mypage (even if I'm being served by the 192.168.1.2 server).
I used wireshark to look at the messages, and HAProxy sometimes sends a 301 response, saying the page has been moved permanently to 192.168.1.1:8000/mypage. The rest of the GET requests for the page's content then go to the :8000 url. Additionally, sometimes even though the link in broswer is to 192.168.1.1/mypage, the initial GET request is still sent to :8000
Is there a way to reconfigure/change HAProxy to not have this behavior? The gist of it is that when I type in a url, I get the right page and the url doesn't change from what I typed in but when I click a link (even to the same page, with the link in broswer being the same), I get the right page BUT my url changes to have the backend port added to it.
My HAProxy config is below
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
stats timeout 30s
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
frontend main
bind *:80
stats enable
stats uri /stats
stats realm HAProxy\ Statistics
stats auth admin:password
default_backend backend_main
backend backend_main
balance roundrobin
option prefer-last-server
cookie server_cookie insert indirect nocache
server s1 192.168.1.1:8000 check cookie s1
server s2 192.168.1.2:8000 check cookie s2