Nikolako
Nikolako

Reputation: 33

How to deploy Flask project on Plesk subdomain

I want to ask if there is a way to deploy my Flask project to a Plesk subdomain. The site is going to be created with wordpress inside Plesk. Also, i would like to have database support.

Upvotes: 3

Views: 1643

Answers (1)

shiny
shiny

Reputation: 668

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

Upvotes: 2

Related Questions