How to deploy Flask project on Plesk subdomain
I was struggeling with a similar issue. What i did was the following:
- Installed nginx
- In the subdomain -> Apache & nginx Settings, make sure to disable the proxy-mode under the nginx settings
add the following to Additional nginx directives:
location / { # Define the location of the proxy server to send the request to proxy_pass http://127.0.0.1:5000; # Redefine the header fields that NGINX sends to the upstream server proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Define the maximum file size on file uploads client_max_body_size 5M;}location /static/ { alias /var/www/vhosts/PATH/TO/FLASK/app/static/;}
The rest is handled by gunicorn, you can find a great tutorial here: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deployment-on-linux
hope that helps