How to deploy Flask project on Plesk subdomain

孤人 提交于 2020-04-13 16:59:42

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/59677879/how-to-deploy-flask-project-on-plesk-subdomain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!