Changes: - fix README.md old json format usage - rename "redirect" option to "proxy_pass" - move docker-compose.yml and nginx.conf.j2 to examples and add to .gitignore - fix situation when one domain from domains.txt and servers.yaml appeared twice in nginx.conf
84 lines
2.4 KiB
Plaintext
84 lines
2.4 KiB
Plaintext
{#- variables ~ examples: #}
|
|
{#- acme_challenge_location ~ /ssl/: #}
|
|
{#- resolver ~ 127.0.0.11: #}
|
|
{#- servers ~ ["name": ..., ("proxy_pass": ..., "server_options": ..., "location_options": ..., "all_names": ..., "port": ..., "ssl_port": ...)]: #}
|
|
{#- #}user nginx;
|
|
worker_processes auto;
|
|
|
|
error_log /var/log/nginx/error.log notice;
|
|
pid /var/run/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_timeout 10m;
|
|
server_tokens off;
|
|
gzip on;
|
|
|
|
proxy_connect_timeout 300;
|
|
proxy_send_timeout 600;
|
|
proxy_read_timeout 600;
|
|
send_timeout 600;
|
|
client_max_body_size 500M;
|
|
|
|
server {
|
|
return 404;
|
|
}
|
|
|
|
{%- for server in servers %}
|
|
{# #}
|
|
server {
|
|
listen {{ server["port"] or 80 }};
|
|
{%- if server["certificate_dir"] is not none %}
|
|
listen {{ server["ssl_port"] or 443 }} ssl;
|
|
ssl_certificate {{ server["certificate_dir"] }}/fullchain.pem;
|
|
ssl_certificate_key {{ server["certificate_dir"] }}/privkey.pem;
|
|
|
|
if ($scheme = 'http') {
|
|
return 302 https://$host$request_uri;
|
|
}
|
|
{%- endif %}
|
|
keepalive_timeout 70;
|
|
|
|
server_name {{ server["all_names"] or server["name"] }};
|
|
|
|
{%- if acme_challenge_location is not none %}
|
|
{# #}
|
|
location /.well-known/acme-challenge {
|
|
root {{ acme_challenge_location }};
|
|
}
|
|
{%- endif %}
|
|
|
|
{%- if server["server_options"]|length > 0 %}
|
|
{# #}
|
|
{%- for server_option in server["server_options"] %}
|
|
{{ server_option }}
|
|
{%- endfor %}
|
|
{%- endif %}
|
|
|
|
{%- if server["proxy_pass"] is not none %}
|
|
{# #}
|
|
location / {
|
|
resolver {{ resolver }};
|
|
set $host_{{ loop.index }} {{ server["proxy_pass"] }};
|
|
proxy_pass $host_{{ loop.index }};
|
|
|
|
proxy_set_header Host $host:$server_port;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
{%- if server["location_options"]|length > 0 %}
|
|
{# #}
|
|
{%- for location_option in server["location_options"] %}
|
|
{{ location_option }}
|
|
{%- endfor %}
|
|
{%- endif %}
|
|
}
|
|
{%- endif %}
|
|
}
|
|
{%- endfor %}
|
|
}
|