Created
August 31, 2023 15:57
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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