############################################
# config file for ${name_site}
############################################
upstream ${name_site}_backend {
server ${name_service};
server 1.1.1.1 backup;
}
server {
server_name ${name_site}.tryton.geeraert.eu www.${name_site}.tryton.geeraert.eu;
%{ if geoip_blocking}
if ($allowed_country_${upper(join("_", sort(geoip_allow)))} = no) {
return 444; # Forbidden
# Or use 'return 444;' to close the connection without a response
# The 444 Status: If you want to save bandwidth and "ghost" attackers, use return 444;. It drops the connection immediately without even sending a "Forbidden" header.
}
%{ endif }
location / {
proxy_pass %{ if proxy_pass_https}https%{else}http%{ endif }://${name_site}_backend;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
${extra-value-location}
%{ if authentication_required}
auth_basic "Administrator’s Area";
auth_basic_user_file /authentication-htpasswd/.htpasswd;
%{ endif }
%{ if proxy_cache}
location ~* \.(html|css|jpg|gif|ico|js)$ {
proxy_cache cache;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 301 302 30m;
expires 30m;
proxy_pass %{ if proxy_pass_https}https%{else}http%{ endif }://${name_site}_backend;
}
%{ endif }
}
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location @f2b-banned {
default_type text/html;
return 403 "
You are banned!";
}
#location ^~ /wp-content {
## Logs the IP in "deny IP;" format to your specific file
# access_log /etc/nginx/blacklisted.d/blacklisted-sessions.conf deny_style;
# access_log /etc/nginx/blacklisted.memory.d/blacklisted-sessions.conf deny_style;
# return 444;
#}
access_log /var/log/nginx/access.log my_custom_format;
access_log /var/log/nginx/ip_audit.log ip_audit;
access_log /var/log/nginx/backend_debug.log backend_debug;
access_log /var/log/nginx/blocked_countries.log blocked_fmt if=$should_log_blocked_${upper(join("_", sort(geoip_allow)))};
${extra-value}
%{~ if http2_bool~}
http2 on;
ssl_protocols TLSv1.2;
%{~ endif ~}
listen 443 ssl;
%{~ if listen_port_80_bool~}
listen 80;
%{~ endif ~}
ssl_certificate /etc/nginx/ssl/live/tryton.geeraert.eu/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/tryton.geeraert.eu/privkey.pem;
}
%{~ if redirect_to_https_bool~}
server {
if ($host = www.${name_site}.tryton.geeraert.eu) {
return 301 https://$host$request_uri;
}
if ($host = ${name_site}.tryton.geeraert.eu) {
return 301 https://$host$request_uri;
}
server_name www.${name_site}.tryton.geeraert.eu ${name_site}.tryton.geeraert.eu ;
listen 80;
return 404;
}
%{~ endif ~}
############################################
# config file for ${name_site}
############################################
upstream ${name_site}_backend_root {
server ${name_service};
server 1.1.1.1 backup;
}
server {
server_name ${name_site}.geeraert.eu www.${name_site}.geeraert.eu;
%{ if geoip_blocking}
if ($allowed_country_${upper(join("_", sort(geoip_allow)))} = no) {
return 444; # Forbidden
# Or use 'return 444;' to close the connection without a response
# The 444 Status: If you want to save bandwidth and "ghost" attackers, use return 444;. It drops the connection immediately without even sending a "Forbidden" header.
}
%{ endif }
location / {
proxy_pass %{ if proxy_pass_https}https%{else}http%{ endif }://${name_site}_backend_root;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
${extra-value-location}
%{ if authentication_required}
auth_basic "Administrator’s Area";
auth_basic_user_file /authentication-htpasswd/.htpasswd;
%{ endif }
%{ if proxy_cache}
location ~* \.(html|css|jpg|gif|ico|js)$ {
proxy_cache cache;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 301 302 30m;
expires 30m;
proxy_pass %{ if proxy_pass_https}https%{else}http%{ endif }://${name_site}_backend_root;
}
%{ endif }
}
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location @f2b-banned {
default_type text/html;
return 403 "
You are banned!";
}
#location ^~ /wp-content {
## Logs the IP in "deny IP;" format to your specific file
# access_log /etc/nginx/blacklisted.d/blacklisted-sessions.conf deny_style;
# access_log /etc/nginx/blacklisted.memory.d/blacklisted-sessions.conf deny_style;
# return 444;
#}
access_log /var/log/nginx/access.log my_custom_format;
access_log /var/log/nginx/ip_audit.log ip_audit;
access_log /var/log/nginx/backend_debug.log backend_debug;
access_log /var/log/nginx/blocked_countries.log blocked_fmt if=$should_log_blocked_${upper(join("_", sort(geoip_allow)))};
${extra-value}
%{~ if http2_bool~}
http2 on;
ssl_protocols TLSv1.2;
%{~ endif ~}
listen 443 ssl;
%{~ if listen_port_80_bool~}
listen 80;
%{~ endif ~}
ssl_certificate /etc/nginx/ssl/live/tryton.geeraert.eu/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/tryton.geeraert.eu/privkey.pem;
}
%{~ if redirect_to_https_bool~}
server {
if ($host = www.${name_site}.geeraert.eu) {
return 301 https://$host$request_uri;
}
if ($host = ${name_site}.geeraert.eu) {
return 301 https://$host$request_uri;
}
server_name www.${name_site}.geeraert.eu ${name_site}.geeraert.eu ;
listen 80;
return 404;
}
%{~ endif ~}