47 lines
1.3 KiB
Plaintext
47 lines
1.3 KiB
Plaintext
|
#jinja2: lstrip_blocks: True
|
||
|
# {{ ansible_managed }}
|
||
|
upstream backend {
|
||
|
server {{ unifi_server_ip }}:{{ unifi_server_port }};
|
||
|
}
|
||
|
|
||
|
server {
|
||
|
listen 80;
|
||
|
server_name {{ unifi_nginx_server_name }};
|
||
|
|
||
|
{% if unifi_nginx_tls_enabled %}
|
||
|
return 301 https://$server_name$request_uri;
|
||
|
{% else %}
|
||
|
location / {
|
||
|
proxy_pass https://backend;
|
||
|
|
||
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
proxy_set_header Connection "Upgrade";
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_set_header X-Real-IP $remote_addr;
|
||
|
proxy_set_header X-Forwarded-Host $server_name;
|
||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
|
}
|
||
|
{% endif %}
|
||
|
}
|
||
|
|
||
|
{% if unifi_nginx_tls_enabled %}
|
||
|
server {
|
||
|
listen 443 ssl;
|
||
|
server_name {{ unifi_nginx_server_name }};
|
||
|
|
||
|
location / {
|
||
|
proxy_pass https://backend;
|
||
|
|
||
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
proxy_set_header Connection "Upgrade";
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_set_header X-Real-IP $remote_addr;
|
||
|
proxy_set_header X-Forwarded-Host $server_name;
|
||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
|
}
|
||
|
|
||
|
ssl_certificate {{ unifi_nginx_tls_cert_file }};
|
||
|
ssl_certificate_key {{ unifi_nginx_tls_key_file }};
|
||
|
}
|
||
|
{% endif %}
|