Redirect url to local ip and different port

Hi All,

I like to redirect a web request to an internal server on a different port. On pfSense I was able to achieve this with the dns resolver and haproxy functionality.

I tried the following on vyos, but could not get it to work:

set load-balancing haproxy service http mode ‘tcp’
set load-balancing haproxy service http port ‘80’

set load-balancing haproxy service http rule 1 domain-name ‘xx.xxxx.local’
set load-balancing haproxy service http rule 1 set backend ‘bk-api-01’
set load-balancing haproxy backend bk-api-01 description ‘bk-api-01’
set load-balancing haproxy backend bk-api-01 mode ‘tcp’
set load-balancing haproxy backend bk-api-01 server api01 address ‘192.168.0.2’
set load-balancing haproxy backend bk-api-01 server api01 port ‘8777’

I also tried with the dns forwarding function in addition.

Would appreciate your support, as this is the last missing piece on my pfsense to vyos migration.

I solved it using the combination of dns forwarding and reverse-proxy as per below:

set service dns forwarding authoritative-domain xxxx.local records a xx address 192.168.0.1

set load-balancing reverse-proxy service http description ‘bind app listen on 80 port’
set load-balancing reverse-proxy service http mode ‘tcp’
set load-balancing reverse-proxy service http port ‘80’

set load-balancing reverse-proxy service http rule 1 domain-name ‘xx.xxxx.local’
set load-balancing reverse-proxy service http rule 1 set backend ‘bk-api-01’
set load-balancing reverse-proxy backend bk-api-01 description ‘My API-1’
set load-balancing reverse-proxy backend bk-api-01 mode ‘tcp’
set load-balancing reverse-proxy backend bk-api-01 server api01 address ‘192.168.0.2’
set load-balancing reverse-proxy backend bk-api-01 server api01 port ‘xxxx’

1 Like

If you don’t need any additional functionality than just providing the port you could also achieve that with a destination NAT rule:

set nat destination rule 10 destination address '192.168.0.1'
set nat destination rule 10 destination port '80'
set nat destination rule 10 protocol 'tcp'
set nat destination rule 10 translation address '192.168.0.2'
set nat destination rule 10 translation port 'xxx'
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.