Reputation:
I've got a flask application, and trying to configure nginx for the app. For now only '/' page is available, another pages got 500 server error. I'm newly in nginx, could you tell me how to fix?
Upvotes: 1
Views: 943
Reputation: 321
I'd recommend a reverse proxy
configuration for something like this.
You Flask application will listen on localhost on port 8888 (for example)
And then Nginx would pass requests to that port internally
Below is a basic config for passing inbound http (port 80) requests to your flask application listening internally on port 8888
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:8888;
}
}
Serving the flask app is another question. uWSGI and Gunicorn are two great wsgi servers that flask will work great with.
EDIT: adding ssl config. (Change the paths to meet your needs)
server {
listen 443 ssl;
server_name www.example.com example.com;
ssl_certificate /etc/letsencrypt/live/example.com/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://127.0.0.1:8888;
}
}
Upvotes: 1