49 lines
1.6 KiB
Plaintext
49 lines
1.6 KiB
Plaintext
|
#jinja2: lstrip_blocks: True
|
||
|
# {{ ansible_managed }}
|
||
|
upstream backend_homeassistant {
|
||
|
server {{ homeassistant_nginx_proxy_url | urlsplit('hostname') }}:{{ homeassistant_nginx_proxy_url | urlsplit('port') }};
|
||
|
}
|
||
|
|
||
|
server {
|
||
|
listen 80;
|
||
|
server_name {{ homeassistant_client_url | urlsplit('hostname') }};
|
||
|
|
||
|
client_max_body_size 200M;
|
||
|
|
||
|
{% if homeassistant_nginx_tls_enabled %}
|
||
|
return 301 https://$server_name$request_uri;
|
||
|
{% else %}
|
||
|
location / {
|
||
|
proxy_pass {{ homeassistant_nginx_proxy_url | urlsplit('scheme') }}://backend_homeassistant;
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_redirect http:// https://;
|
||
|
proxy_http_version 1.1;
|
||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
proxy_set_header Connection $connection_upgrade;
|
||
|
}
|
||
|
{% endif %}
|
||
|
}
|
||
|
|
||
|
{% if homeassistant_nginx_tls_enabled %}
|
||
|
server {
|
||
|
listen 443 ssl;
|
||
|
server_name {{ homeassistant_client_url | urlsplit('hostname') }};
|
||
|
|
||
|
client_max_body_size 200M;
|
||
|
|
||
|
location / {
|
||
|
proxy_pass {{ homeassistant_nginx_proxy_url | urlsplit('scheme') }}://backend_homeassistant;
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_redirect http:// https://;
|
||
|
proxy_http_version 1.1;
|
||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
proxy_set_header Connection $connection_upgrade;
|
||
|
}
|
||
|
|
||
|
ssl_certificate /etc/pki/tls/certs/{{ homeassistant_nginx_tls_cert_file }};
|
||
|
ssl_certificate_key /etc/pki/tls/private/{{ homeassistant_nginx_tls_key_file }};
|
||
|
}
|
||
|
{% endif %}
|