Hi all,
Since I want to host 2 web servers under 1 public IP, I'd like to see if my RB450Gx4 can be used as a reverse proxy.
Says there are:
abc.com@192.168.88.5
xyz.com@192.168.88.7
I have followed the below steps to setup:
/ip proxy set enabled=yes src-address=0.0.0.0
/ip dns static
add address=192.168.88.5 name=abc.com
add address=192.168.88.7 name=xyz.com
/ip firewall nat
add action=redirect chain=dstnat dst-address=[public IP] dst-port=80 protocol=tcp to-ports=8080
In LAN, the setting can successfully bring me to the right server with different domain name. However, it didn't work if I tried to connect from WAN. I could see the packets coming in NAT but no connection was built by proxy.
Thanks for any help!
There were more much suitable for this task like deploying a port forwarding on a real proxy like haproxy and handle this on L7 so that you can achieved what you want. because port forwarding can only be done once on a specific port.
For illustration purposes only
your external IP is 1.1.1.1 and you map it to port 80 and DNAT to 192.168.88.5:80 for abc.com
1.1.1.1:80 -> 192.168.88.5.80 (abc.com)
1.1.1.1:80 -> 192.168.88.7.80 (xyz.com) # This will not work because you already mapped it on your previous rule
Solution
1.1.1.1:80 -> 192.168.88.4:80 (haproxy = real reverse proxy) handle the application routing/logic here much more versatile and you can even use different operating system behind on the reverse proxy