• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question Port Forwarding

Sysop

Basic Pleskian
How can I forward certain IP traffic coming from port 80 to another port on my server (eg. Port 7272)?

Screen Shot 2021-04-30 at 12.34.48 PM.png
I tried to do this from within Plesk Firewall but I get an error stating "Invalid IP address or network." (eg. Destination IP = 25.25.25.25:7272).
 
You could try and use something like:

Additional nginx directives

Code:
location = / {
return 301 https://domain.tld:7272;
}

I hope it helps.
 
Better to use proxy_pass for a transparent redirect.
Also, this will probably conflict with redirect to https if that is active in nginx. Port redirecting by firewall would still work because it catches the packets before nginx.
 
Better to use proxy_pass for a transparent redirect.
Also, this will probably conflict with redirect to https if that is active in nginx. Port redirecting by firewall would still work because it catches the packets before nginx.
I was wanting to use the firewall although when i installed firewalld it conflicted with the Plesk firewall, so I’m not quite sure how to handle that.

Do you have an example of the nginx directive to use proxy pass in the way you describe?

Thanks!
 
I was wanting to use the firewall although when i installed firewalld it conflicted with the Plesk firewall, so I’m not quite sure how to handle that.

Do you have an example of the nginx directive to use proxy pass in the way you describe?

Thanks!
Note: there's been three different solutions mentioned.

a) a redirect - this will receive an HTTP request, and respond with a location header asking the browser to access the new URL. Likely not what you want.
b) a HTTP proxy - this was receive the HTTP request, and send that same request to the server you're proxying to, then return that response to the browser. Ths can act as a "port forwarder" - but this only operates on an application level, in this case, HTTP.
c) port forwarding can also be done at a lower level that'll pass all, or some connections to the port. IPTables is a great solution for this: Linux Port Forwarding Using iptables - SysTutorials. This is the solution you want if you're not forwarding HTTP traffic

The implication for c) is that all traffic that matches the rule will get forwarded. Since you're on 80, all HTTP traffic will be forwarded to 7272, whether you want to or not. Therefore, if you've also got Apache listening on the IP you want to port-forward, Apache will no longer server the requests as the firewall steps in before Apache even gets the request.
 
Back
Top