2022-12-01 14:42:01 +01:00
|
|
|
#include /etc/nginx/conf.d/sub/cache-uwsgi.conf;
|
2022-11-24 13:32:59 +01:00
|
|
|
|
|
|
|
upstream flask_server {
|
|
|
|
# ip_hash;
|
|
|
|
server flask_website:8080;
|
|
|
|
# server flask_website:8080 weight=1 max_fails=3 fail_timeout=30s;
|
|
|
|
|
|
|
|
# Or: server unix:/app/flask_server.sock;
|
|
|
|
}
|
|
|
|
|
2022-11-30 16:52:28 +01:00
|
|
|
# Redirect all http requests to the main server wordpress_server
|
2022-11-24 13:32:59 +01:00
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
|
|
|
|
2022-11-30 19:20:41 +01:00
|
|
|
server_name bensuperpc.org www.bensuperpc.org flask.bensuperpc.org www.flask.bensuperpc.org;
|
2022-11-30 16:52:28 +01:00
|
|
|
|
|
|
|
location ~ /.well-known/acme-challenge {
|
|
|
|
allow all;
|
|
|
|
root /var/www/flask;
|
|
|
|
}
|
|
|
|
|
|
|
|
location / {
|
|
|
|
return 301 https://$host$request_uri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
server {
|
2022-11-30 19:20:41 +01:00
|
|
|
listen 443 ssl http2;
|
|
|
|
listen [::]:443 ssl http2;
|
2022-11-30 16:52:28 +01:00
|
|
|
|
|
|
|
server_name bensuperpc.org www.bensuperpc.org flask.bensuperpc.org www.flask.bensuperpc.org;
|
2022-11-24 13:32:59 +01:00
|
|
|
|
|
|
|
include /etc/nginx/conf.d/sub/gzip.conf;
|
|
|
|
|
2022-11-30 16:52:28 +01:00
|
|
|
# All things related to SSL
|
|
|
|
ssl_certificate /etc/letsencrypt/live/bensuperpc.org/fullchain.pem;
|
|
|
|
ssl_certificate_key /etc/letsencrypt/live/bensuperpc.org/privkey.pem;
|
|
|
|
ssl_trusted_certificate /etc/letsencrypt/live/bensuperpc.org/chain.pem;
|
|
|
|
#ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
|
|
|
#add_header Strict-Transport-Security "max-age=31536000" always;
|
|
|
|
|
|
|
|
include /etc/nginx/conf.d/sub/options-ssl-nginx.conf;
|
|
|
|
|
2022-12-01 14:42:01 +01:00
|
|
|
#set $skip_cache 1;
|
|
|
|
#set $skip_reason "Disabled for now";
|
|
|
|
|
|
|
|
#if ($request_method = POST) {
|
|
|
|
# set $skip_cache 1;
|
|
|
|
# set $skip_reason "POST request";
|
|
|
|
#}
|
|
|
|
|
|
|
|
#if ($request_uri ~* "(/admin/|/logout|/login)") {
|
|
|
|
# set $skip_cache 1;
|
|
|
|
# set $skip_reason "request_uri";
|
|
|
|
#}
|
|
|
|
|
|
|
|
#if ($http_cookie ~* "remember_token") {
|
|
|
|
# set $skip_cache 1;
|
|
|
|
# set $skip_reason "${skip_reason}-http_cookie";
|
|
|
|
#}
|
|
|
|
|
2022-11-24 13:32:59 +01:00
|
|
|
location / { try_files $uri @flask_app; }
|
|
|
|
|
|
|
|
location @flask_app {
|
|
|
|
include uwsgi_params;
|
|
|
|
uwsgi_pass flask_server;
|
2022-11-26 15:08:56 +01:00
|
|
|
|
|
|
|
uwsgi_buffering on;
|
|
|
|
uwsgi_buffers 8 16k;
|
2022-12-01 14:42:01 +01:00
|
|
|
|
|
|
|
#uwsgi_cache_bypass $skip_cache;
|
|
|
|
#uwsgi_no_cache $skip_cache;
|
2022-11-24 13:32:59 +01:00
|
|
|
|
2022-12-01 14:42:01 +01:00
|
|
|
#uwsgi_cache_valid 200 302 10m;
|
|
|
|
#uwsgi_cache_valid 301 1h;
|
|
|
|
#uwsgi_cache_valid any 1m;
|
|
|
|
#uwsgi_cache_lock on;
|
2022-11-24 13:32:59 +01:00
|
|
|
|
2022-11-30 16:52:28 +01:00
|
|
|
#uwsgi_ignore_headers Vary;
|
2022-11-24 13:32:59 +01:00
|
|
|
#uwsgi_hide_header Vary;
|
|
|
|
|
2022-12-01 14:42:01 +01:00
|
|
|
#uwsgi_ignore_headers Expires Cache-Control Set-Cookie Vary;
|
|
|
|
#uwsgi_hide_header Vary;
|
|
|
|
|
|
|
|
#add_header X-cache $upstream_cache_status;
|
|
|
|
#add_header X-cache-reason $skip_reason;
|
2022-11-26 15:08:56 +01:00
|
|
|
|
2022-12-01 14:42:01 +01:00
|
|
|
#uwsgi_cache UWSGI;
|
2022-11-24 13:32:59 +01:00
|
|
|
}
|
2022-11-30 16:52:28 +01:00
|
|
|
|
|
|
|
# Don't write to accesslog for these files
|
|
|
|
location = /favicon.ico {
|
|
|
|
log_not_found off;
|
|
|
|
access_log off;
|
|
|
|
}
|
|
|
|
location = /robots.txt {
|
|
|
|
allow all;
|
|
|
|
log_not_found off;
|
|
|
|
access_log off;
|
|
|
|
}
|
2022-11-24 13:32:59 +01:00
|
|
|
}
|