{% if server.http_redirect is defined and server.http_redirect %} server { listen 80; listen [::]:80; server_name {{ server.name }}; return 301 https://$server_name$request_uri; } {% endif %} {% if server.proxy is defined and server.proxy.cache is defined and server.proxy.cache %} proxy_cache_path /usr/share/nginx/cache_{{ short_name }} levels=1:2 keys_zone=cache_{{ short_name }}:10m max_size=100m inactive=60m use_temp_path=off; {% endif %} server { {% if server.http_redirect is not defined or not server.http_redirect %} listen 80; listen [::]:80; {% endif %} listen 443 ssl http2; listen [::]:443 ssl http2; server_name {{ server.name }} {{server.aliases|default([])| join(' ')}}; location / { {% if server.dir is defined %} root {{ server.dir }}; index index.html; {% endif %} {% if server.proxy is defined %} proxy_pass http://{{server.proxy.host|default("127.0.0.1")}}:{{server.proxy.port|default("80")}}; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Scheme $scheme; proxy_redirect off; proxy_http_version 1.1; {% if server.websocket is defined and server.websocket %} proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; {% endif %} {% if server.proxy is defined %} {% if server.proxy.keepalive is defined and server.proxy.keepalive %} proxy_socket_keepalive on; {% endif %} {% if server.proxy.timeout is defined %} proxy_connect_timeout {{ server.proxy.timeout }}; {% endif %} {% if server.proxy.cache is defined and server.proxy.cache %} proxy_cache cache_{{ short_name }}; proxy_cache_revalidate on; {% endif %} {% if server.proxy.cache_when_origin_down is defined and server.proxy.cache_when_origin_down %} proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504; {% endif %} {% endif %} {% if server.client_body_size is defined %} client_max_body_size {{ server.client_body_size }}; {% endif %} {% endif %} } location = /50x.html { root /usr/share/nginx/html; } location ~ (\.env|wp-login\.php|wp-admin) { return 301 https://www.youtube.com/watch?v=dQw4w9WgXcQ; } {% for key in (server.headers|default([])) %} add_header {{ key }} "{{ server.headers[key] }}" always; {% endfor %} }