Files
athq-vm-management/templates/nginx_server_block.conf.j2
2025-02-28 16:15:51 +01:00

86 lines
2.1 KiB
Django/Jinja

{% if terminate_ssl %}
server{
# {{ comment }}
listen 10443 ssl;
listen [::]:10443 ssl;
{% if servernames %}server_name{% for s in servernames %} {{ s }}{% endfor %};{% endif %}
{% if acme %}
include acme-challenge.conf;
{% else %}
listen 80;
listen [::]:80;
{% endif %}
{% if cert_optional %}
ssl_client_certificate ca_cert.pem;
{% if cert_non_optional %}
ssl_verify_client on;
{% else %}
ssl_verify_client optional;
{% endif %}
ssl_verify_depth 1;
{% endif %}
{% if extra_location and not extra_location["location"] == "/" %}
location {{ extra_location["location"] }} {
{{ extra_location["content"] }}
{% if extra_location["location-auth"] %}
auth_basic "{{ extra_location["location-auth"] }}";
auth_basic_user_file /etc/nginx/{{ extra_location["location-auth"] }}.htpasswd;
{% endif %}
}
{% endif %}
location / {
proxy_pass http://{{ targetip }}:{{ targetport }};
proxy_set_header Host $http_host;
{% if extra_location["location"] == "/" %}
{{ extra_location["content"] }}
{% endif %}
{{ proxy_pass_blob }}
{{ cert_header_line }}
{% if basicauth %}
auth_basic "{{ basicauth }}";
auth_basic_user_file /etc/nginx/{{ basicauth }}.htpasswd;
{% endif %}
}
}
{% endif %}
server{
# {{ comment }}
listen 80;
listen [::]:80;
{% if include_subdomains %}
{% if servernames %}
server_name{% for s in servernames %} ~^.*{{ s.replace(".","\\.") }}{% endfor %};
{% endif %}
{% else %}
{% if servernames %}server_name{% for s in servernames %} {{ s }}{% endfor %};{% endif %}
{% endif %}
{% if acme %}
include acme-challenge.conf;
return 301 https://$host$request_uri;
{% else %}
location / {
{{ proxy_pass_blob }}
{% if http_target_port %}
proxy_pass http://{{ targetip }}:{{ http_target_port }};
{% else %}
proxy_pass http://{{ targetip }}:80;
{% endif %}
}
{% endif %}
}