From 21215aa9d0cdd1c2e322a6c8faf93ae727e3ce96 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Wed, 22 Dec 2021 13:51:10 -0300 Subject: [PATCH] Allow use of ports other than 8123 in HA (#2307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joakim Sørensen --- nginx_proxy/CHANGELOG.md | 4 ++++ nginx_proxy/config.yaml | 3 ++- nginx_proxy/data/nginx.conf | 2 +- nginx_proxy/data/run.sh | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nginx_proxy/CHANGELOG.md b/nginx_proxy/CHANGELOG.md index 5c6c4b9..158b8fd 100644 --- a/nginx_proxy/CHANGELOG.md +++ b/nginx_proxy/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.1.0 + +- Allow use of ports other than 8123 in Home Assistant Core + ## 3.0.2 - Update Alpine to 3.14 diff --git a/nginx_proxy/config.yaml b/nginx_proxy/config.yaml index 58375f9..8affef9 100644 --- a/nginx_proxy/config.yaml +++ b/nginx_proxy/config.yaml @@ -1,4 +1,5 @@ -version: 3.0.2 +version: 3.1.0 +hassio_api: true slug: nginx_proxy name: NGINX Home Assistant SSL proxy description: An SSL/TLS proxy diff --git a/nginx_proxy/data/nginx.conf b/nginx_proxy/data/nginx.conf index fdc091f..ebd7815 100644 --- a/nginx_proxy/data/nginx.conf +++ b/nginx_proxy/data/nginx.conf @@ -58,7 +58,7 @@ http { #include /share/nginx_proxy_default*.conf; location / { - proxy_pass http://homeassistant.local.hass.io:8123; + proxy_pass http://homeassistant.local.hass.io:%%HA_PORT%%; proxy_set_header Host $host; proxy_redirect http:// https://; proxy_http_version 1.1; diff --git a/nginx_proxy/data/run.sh b/nginx_proxy/data/run.sh index 6e26713..55fc1cc 100755 --- a/nginx_proxy/data/run.sh +++ b/nginx_proxy/data/run.sh @@ -13,6 +13,8 @@ KEYFILE=$(bashio::config 'keyfile') CERTFILE=$(bashio::config 'certfile') HSTS=$(bashio::config 'hsts') +HA_PORT=$(bashio::core.port) + # Generate dhparams if ! bashio::fs.file_exists "${DHPARAMS_PATH}"; then bashio::log.info "Generating dhparams (this will take some time)..." @@ -52,6 +54,7 @@ fi sed -i "s#%%FULLCHAIN%%#$CERTFILE#g" /etc/nginx.conf sed -i "s#%%PRIVKEY%%#$KEYFILE#g" /etc/nginx.conf sed -i "s/%%DOMAIN%%/$DOMAIN/g" /etc/nginx.conf +sed -i "s/%%HA_PORT%%/$HA_PORT/g" /etc/nginx.conf [ -n "$HSTS" ] && HSTS="add_header Strict-Transport-Security \"$HSTS\" always;" sed -i "s/%%HSTS%%/$HSTS/g" /etc/nginx.conf