Answer the question
In order to leave comments, you need to log in
NGINX + FLASK + Gunicorn configuration. How to configure proxying to a server subdirectory?
There is a configured VPS with NGINX + Gunicorn + Flask
When accessing the "IP server" the application works.
How can I change the config so that when I access a url like "server IP/python_dev" my application opens?
If I use location /python_dev the error is "Not Found. The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again." when accessing
Nginx config:
server {
listen 80;
server_name _;
location / {
include proxy_params;
proxy_pass http://unix:/home/it/python_dev/myproject.sock;
}
}
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
app.run('0.0.0.0')
[Unit]
Description=Gunicorn instance to serve myproject
After=network.target
[Service]
User=it
Group=www-data
WorkingDirectory=/home/it/python_dev
Environment="PATH=/home/it/python_dev/env/bin"
ExecStart=/home/it/python_dev/env/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question