• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

Question Flask app on port 80

rayder99

New Pleskian
Server operating system version
Ubuntu 20.04.6
Plesk version and microupdate number
Obsidian 18.0.61
Hello Everybody,

I followed this manual to create a flask app and run it in Plesk Obsidian:
Input - Guide for Python Flask App deployement

But my problem is, that this app only runs on port 5000, or whichever i define in the parameters.
It does not run on port 80, so the standard port for http traffic - I get this message:
"Port 80 is in use by another program. Either identify and stop that program, or start the server with a different port."

How can i change the default port, that traffic for port 80 will be redirected to 5000? - or whichever port I choose
And as Step 2: how can i make the https traffic as well to go to my flask app?

Many thanks in advance
 
That where proxying request comes into play. You can run Flask (or any other application) on a different port (example 5000) and proxy all requests made to a domain on port 80 (and 443 for https) to 5000.

Simply by disabling proxy mode in Plesk and adding this Ngnix directive to the additional directives of the domain. You can adapt the directive for your specific needs and configuration.
NGINX:
<Location />
ProxyPass http://127.0.0.1:5000
ProxyPassReverse http://127.0.0.1:5000
</Location>
 
That where proxying request comes into play. You can run Flask (or any other application) on a different port (example 5000) and proxy all requests made to a domain on port 80 (and 443 for https) to 5000.

Simply by disabling proxy mode in Plesk and adding this Ngnix directive to the additional directives of the domain. You can adapt the directive for your specific needs and configuration.
NGINX:
<Location />
ProxyPass http://127.0.0.1:5000
ProxyPassReverse http://127.0.0.1:5000
</Location>
Please excuse my lack of understanding: where exactly do I have to add this proxy-pass information? which file? or which menu/settings?
 
You can add them under the Domain in Plesk, when you go to Hosting & DNS > Apache & nginx Settings under
Additional nginx directives.
In that same menu 1st disable the option "Proxy mode" if it is enabled
 
Back
Top