Skip to content

Instantly share code, notes, and snippets.

@linux4life798
Last active April 19, 2025 05:50
Show Gist options
  • Save linux4life798/581b24155aef90e59a66bee1e25accd1 to your computer and use it in GitHub Desktop.
Save linux4life798/581b24155aef90e59a66bee1e25accd1 to your computer and use it in GitHub Desktop.
Change Home Assistant NGINX SSL Proxy Listening Port
# /share/nginx_proxy_default.conf
# Blank.
# /share/nginx/port55555.conf
# We can't override the port, so we create a new server listening
# on port 55555. Then, change the pass throug port in the add-on configuration.
# Change the Customize "active" field to true.
#
# It appears that template evaluation works on this conf file,
# recursively.
#
# https://github.com/home-assistant/addons/blob/master/nginx_proxy/rootfs/etc/nginx/nginx.conf.gtpl
server {
server_name {{ .options.domain }};
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_certificate /ssl/{{ .options.certfile }};
ssl_certificate_key /ssl/{{ .options.keyfile }};
# dhparams file
ssl_dhparam /data/dhparams.pem;
{{- if not .options.real_ip_from }}
listen 55555 ssl;
http2 on;
{{- else }}
listen 55555 ssl proxy_protocol;
http2 on;
{{- range .options.real_ip_from }}
set_real_ip_from {{.}};
{{- end }}
real_ip_header proxy_protocol;
{{- end }}
{{- if .options.hsts }}
add_header Strict-Transport-Security "{{ .options.hsts }}" always;
{{- end }}
proxy_buffering off;
{{- if .options.customize.active }}
include /share/{{ .options.customize.default }};
{{- end }}
location / {
proxy_pass http://homeassistant.local.hass.io:{{ .variables.port }};
proxy_set_header Host $http_host;
proxy_redirect http:// https://;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-Host $http_host;
{{- if not .options.real_ip_from }}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
{{- else }}
proxy_set_header X-Real-IP $proxy_protocol_addr;
proxy_set_header X-Forwarded-For $proxy_protocol_addr;
{{- end }}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment