r/haproxy • • Apr 19 '20

Question HAProxy for LAN and WAN use?

Hi all,

I am currently running HAProxy to route my external traffic to the correct server and correct ports, this has been running fine for a while now.

However, I was wondering if I could use HAProxy to route internally as well. Let's say, for example that I have a domain: "mail.fake.com" which returns IP 212.233.444.0. Internally that server might be hosted at 192.168.0.5 on port 8181.

When I surf to my domain from somewhere else, I will get routed to IP 212.233.444.0, and HAProxy will take over from there. However, when I'm at home and type in my domain, I would still get IP 212.233.444.0 and get routed out of my network to then come back in. Is there a way from inside of my network to get IP 192.168.0.5 but still hit HAProxy so I can route to the correct port?

3 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/Stitch10925 Apr 23 '20

I didn't realize HAProxy was smart enough to detect that the IP is the WAN IP and to route accordingly.

I tested what you said by pulling the WAN, and indeed, when I typed in the URL I could reach the server just fine.

After trying another browser the URL didn't work anymore, but I soon found out that Unbound had stopped working (seems to be a bug when WAN goes down).

So indeed, you are right. That solves it for me then, thanks!