-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 Configure Adguard port/protocol dynamically on startup (#67)
- Loading branch information
1 parent
56e8e28
commit edd538a
Showing
6 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,23 @@ | |
# Home Assistant Community Add-on: AdGuard Home | ||
# Configures NGINX for use with the AdGuard Home server | ||
# ============================================================================== | ||
declare adguard_port=45158 | ||
declare adguard_protocol=http | ||
declare admin_port | ||
declare certfile | ||
declare dns_host | ||
declare ingress_interface | ||
declare ingress_port | ||
declare keyfile | ||
|
||
if bashio::var.true "$(yq read /data/adguard/AdGuardHome.yaml tls.enabled)"; then | ||
adguard_port=$(yq read /data/adguard/AdGuardHome.yaml tls.port_https) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
frenck
Member
|
||
adguard_protocol=https | ||
fi | ||
|
||
sed -i "s#%%port%%#${adguard_port}#g" /etc/nginx/includes/upstream.conf | ||
sed -i "s#%%protocol%%#${adguard_protocol}#g" /etc/nginx/servers/ingress.conf | ||
|
||
admin_port=$(bashio::addon.port 80) | ||
if bashio::var.has_value "${admin_port}"; then | ||
bashio::config.require.ssl | ||
|
@@ -27,6 +37,7 @@ if bashio::var.has_value "${admin_port}"; then | |
fi | ||
|
||
sed -i "s/%%port%%/${admin_port}/g" /etc/nginx/servers/direct.conf | ||
sed -i "s#%%protocol%%#${adguard_protocol}#g" /etc/nginx/servers/direct.conf | ||
fi | ||
|
||
ingress_port=$(bashio::addon.ingress_port) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
upstream backend { | ||
server 127.0.0.1:45158; | ||
server 127.0.0.1:%%port%%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ server { | |
allow 172.30.32.2; | ||
deny all; | ||
|
||
proxy_pass http://backend; | ||
proxy_pass %%protocol%%://backend; | ||
} | ||
} |
This is NOT safe. If the admin interface has left this blank (you can have TLS without HTTPS support) things crash on startup.
[11:39:22] INFO: Starting NGinx...
nginx: [emerg] invalid port in upstream "127.0.0.1:0" in /etc/nginx/includes/upstream.conf:2