File: //etc/nginx/sites-enabled/swisshoney.ru.conf
upstream python_swisshoney_ru {
server unix:/srv/projects/env2/run/gunicorn.sock fail_timeout=0;
}
server {
if ($host = swisshoney.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = www.swisshoney.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen [::]:80;
listen 80;
server_name swisshoney.ru www.swisshoney.ru;
#include letsencrypt/certbot.conf;
root /srv/projects/env2/src;
location /.well-known/acme-challenge {
root /srv/letsencrypt;
allow all;
}
location /static {
alias /srv/projects/env2/src/static;
autoindex off;
}
#location = /robots.txt {
# log_not_found off;
# access_log off;
# return 200 "Host: https://swisshoney.ru\n";
#}
location = /favicon.ico$ {
log_not_found off;
access_log off;
alias /srv/projects/env2/src/static/favicons/favicon.ico;
}
location / {
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
#proxy_redirect off;
#proxy_pass http://python_swisshoney_ru;
return 301 https://swisshoney.ru$request_uri;
}
error_log /var/log/nginx/swisshoney.ru_error.log;
access_log /var/log/nginx/swisshoney.ru_access.log;
#include gzip.conf;
#include h5bp/advanced.conf;
#return 301 https://$server_name$request_uri;
#return 301 https://swisshoney.ru$request_uri;
}
server {
listen [::]:443 ssl;
listen 443 ssl;
http2 on;
server_name www.swisshoney.ru;
include h5bp/advanced.conf;
# SSL
ssl_certificate /etc/letsencrypt/live/swisshoney.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/swisshoney.ru/privkey.pem; # managed by Certbot
# OCSP stapling
ssl_trusted_certificate /etc/letsencrypt/live/swisshoney.ru/fullchain.pem;
return 301 https://swisshoney.ru$request_uri;
}
server {
listen [::]:443 ssl;
listen 443 ssl;
http2 on;
server_name swisshoney.ru;
root /srv/projects/env2/src;
# # Do not allow access to files giving away your WordPress version
# location ~ /(\.|wp-config.php|readme.html|licence.txt) {
# return 404;
# }
location /static {
alias /srv/projects/env2/src/static;
autoindex off;
}
#location = /robots.txt {
# log_not_found off;
# access_log off;
# return 200 "Host: https://swisshoney.ru\n";
#}
location = /favicon.ico$ {
log_not_found off;
access_log off;
alias /srv/projects/env2/src/static/favicons/favicon.ico;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://python_swisshoney_ru;
#return 301 https://swisshoney.ru$request_uri;
}
# SSL
ssl_certificate /etc/letsencrypt/live/swisshoney.ru/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/swisshoney.ru/privkey.pem; # managed by Certbot
# OCSP stapling
ssl_trusted_certificate /etc/letsencrypt/live/swisshoney.ru/fullchain.pem;
charset utf-8;
# # Deliver 404 instead of 403 "Forbidden"
# error_page 403 = 404;
#
# # Custom 404 page
# error_page 404 /404.html;
# location = /404.html {
# root /var/www/swisshoney.ru/errors;
# internal;
# }
#
# # Custom 50x pages
# #error_page 500 502 503 504 = /50x.html;
# #location = /50x.html {
# # root /var/www/swisshoney.ru/errors;
# # internal;
# #}
#
# error_page 500 = /500.html;
# location = /500.html {
# root /var/www/swisshoney.ru/errors;
# internal;
# }
# error_page 502 = /502.html;
# location = /502.html {
# root /var/www/swisshoney.ru/errors;
# internal;
# }
# error_page 503 = /503.html;
# location = /503.html {
# root /var/www/swisshoney.ru/errors;
# internal;
# }
# error_page 504 = /504.html;
# location = /504.html {
# root /var/www/swisshoney.ru/errors;
# internal;
# }
error_log /var/log/nginx/swisshoney.ru_error.log;
access_log /var/log/nginx/swisshoney.ru_access.log;
include gzip.conf;
include h5bp/advanced.conf;
}