2018-08-13 20:06:00 +00:00
|
|
|
#jinja2: lstrip_blocks: True
|
|
|
|
# {{ ansible_managed }}
|
2018-10-26 20:02:33 +00:00
|
|
|
upstream backend_unifi {
|
2018-08-13 20:06:00 +00:00
|
|
|
server {{ unifi_server_ip }}:{{ unifi_server_port }};
|
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen 80;
|
2018-08-17 17:23:55 +00:00
|
|
|
server_name {{ unifi_server_name }};
|
2018-08-13 20:06:00 +00:00
|
|
|
|
|
|
|
{% if unifi_nginx_tls_enabled %}
|
|
|
|
return 301 https://$server_name$request_uri;
|
|
|
|
{% else %}
|
|
|
|
location / {
|
2018-10-26 20:02:33 +00:00
|
|
|
proxy_pass https://backend_unifi;
|
2018-08-13 20:06:00 +00:00
|
|
|
|
|
|
|
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;
|
2018-08-17 17:23:55 +00:00
|
|
|
server_name {{ unifi_server_name }};
|
2018-08-13 20:06:00 +00:00
|
|
|
|
|
|
|
location / {
|
2018-10-26 20:02:33 +00:00
|
|
|
proxy_pass https://backend_unifi;
|
2018-08-13 20:06:00 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-08-14 21:36:09 +00:00
|
|
|
ssl_certificate /etc/pki/tls/certs/{{ unifi_nginx_tls_cert_file }};
|
|
|
|
ssl_certificate_key /etc/pki/tls/private/{{ unifi_nginx_tls_key_file }};
|
2018-08-13 20:06:00 +00:00
|
|
|
}
|
|
|
|
{% endif %}
|