Skip to content

Instantly share code, notes, and snippets.

@filipecifali
Created September 3, 2018 20:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filipecifali/e03d2ca787e759fd153c3dd57ffaa4b3 to your computer and use it in GitHub Desktop.
Save filipecifali/e03d2ca787e759fd153c3dd57ffaa4b3 to your computer and use it in GitHub Desktop.
nginx template
# Flask APP 1
upstream app_{{ core_version }}_{{ item }} {
server unix://{{ core_app_var_dir }}/gunicorn.socket;
}
# Flask APP 2
upstream app_{{ auth_version }}_{{ item }} {
server unix://{{ auth_app_var_dir }}/gunicorn.socket;
}
server {
listen 443 ssl;
server_name {{ item }} www.{{ item }};
listen 80;
server_name localhost {{ item }} www.{{ item }};
ssl_certificate /etc/letsencrypt/live/{{ item }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ item }}/privkey.pem;
access_log /var/log/app/nginx_access.log;
error_log /var/log/app/nginx_error.log;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 60s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffering off;
proxy_temp_file_write_size 64k;
proxy_pass http://app_{{ core_version }}_{{ item }};
proxy_redirect off;
}
location /static {
root {{ core_app_deploy_dir }}/{{ flask_main_module }}/static;
expires 30d;
add_header Cache-Control public;
rewrite ^/static(.*) $1 break;
}
location /auth {
proxy_pass http://app_{{ auth_version }}_{{ item }};
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment