Skip to content

Instantly share code, notes, and snippets.

@riyas-rawther
Created August 31, 2023 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riyas-rawther/bcee20e546b61eff8bea3516d7fe0bb6 to your computer and use it in GitHub Desktop.
Save riyas-rawther/bcee20e546b61eff8bea3516d7fe0bb6 to your computer and use it in GitHub Desktop.
NGINX configuration file for multiple Python Flask applications with reverse proxy. Use this config file to have dedicated static files per location (nested)
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
# SSL
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
# security
#include nginxconfig.io/security.conf;
# logging
access_log /var/log/nginx/access.log combined buffer=512k flush=1m;
error_log /var/log/nginx/error.log warn;
# reverse proxy
location / {
proxy_pass http://127.0.0.1:8000;
location ~* \.(js|jpg|png|css)$ {
try_files $uri =404;
include /etc/nginx/mime.types;
alias /home/azureuser/Project/chatbot/;
}
}
location /detection {
proxy_pass http://127.0.0.1:5000;
location ~* \.(js|jpg|png|css)$ {
try_files $uri =404;
include /etc/nginx/mime.types;
alias /home/azureuser/Project/Car_Detetection/detection/app/;
}
}
# additional config
include nginxconfig.io/general.conf;
}
# subdomains redirect
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name *.example.com;
# SSL
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
return 301 https://example.com$request_uri;
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name .example.com;
include nginxconfig.io/letsencrypt.conf;
location / {
return 301 https://example.com$request_uri;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment