mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-06 05:58:47 +02:00
Modify ingress script for NGINX configuration
This commit is contained in:
@@ -8,22 +8,26 @@ SUBFOLDER="$(bashio::addon.ingress_entry)"
|
|||||||
|
|
||||||
# Copy template
|
# Copy template
|
||||||
cp /defaults/default.conf "${NGINX_CONFIG}"
|
cp /defaults/default.conf "${NGINX_CONFIG}"
|
||||||
# Remove ssl part
|
|
||||||
|
# Keep only the first (non-SSL) server block
|
||||||
awk -v n=4 '/server/{n--}; n > 0' "${NGINX_CONFIG}" > tmpfile
|
awk -v n=4 '/server/{n--}; n > 0' "${NGINX_CONFIG}" > tmpfile
|
||||||
mv tmpfile "${NGINX_CONFIG}"
|
mv tmpfile "${NGINX_CONFIG}"
|
||||||
|
|
||||||
# Remove ipv6
|
# Remove ipv6
|
||||||
sed -i '/listen \[::\]/d' "${NGINX_CONFIG}"
|
sed -i '/listen \[::\]/d' "${NGINX_CONFIG}"
|
||||||
# Add ingress parameters
|
|
||||||
sed -i "s|3000|$(bashio::addon.ingress_port)|g" "${NGINX_CONFIG}"
|
|
||||||
sed -i '/proxy_buffering/a proxy_set_header Accept-Encoding "";' "${NGINX_CONFIG}"
|
|
||||||
sed -i '/proxy_buffering/a sub_filter_once off;' "${NGINX_CONFIG}"
|
|
||||||
sed -i '/proxy_buffering/a sub_filter_types *;' "${NGINX_CONFIG}"
|
|
||||||
sed -i '/proxy_buffering/a sub_filter "vnc/index.html?autoconnect" "vnc/index.html?path=%%path%%/websockify?autoconnect";' "${NGINX_CONFIG}"
|
|
||||||
sed -i "s|%%path%%|${SUBFOLDER:1}|g" "${NGINX_CONFIG}"
|
|
||||||
|
|
||||||
# Correct image
|
# Use ingress port
|
||||||
sed -i "s|SUBFOLDERwebsock|/websock|g" "${NGINX_CONFIG}"
|
sed -i "s|3000|$(bashio::addon.ingress_port)|g" "${NGINX_CONFIG}"
|
||||||
|
|
||||||
|
# Put /devmode under the ingress path and fix SUBFOLDER-prefixed paths
|
||||||
|
sed -i 's|location /devmode|location SUBFOLDER/devmode|g' "${NGINX_CONFIG}"
|
||||||
|
sed -i 's|SUBFOLDER\([A-Za-z]\)|SUBFOLDER/\1|g' "${NGINX_CONFIG}"
|
||||||
|
sed -i 's|SUBFOLDER50x\.html|SUBFOLDER/50x.html|g' "${NGINX_CONFIG}"
|
||||||
|
sed -i "s|SUBFOLDER|${SUBFOLDER%/}|g" "${NGINX_CONFIG}"
|
||||||
|
|
||||||
|
# Replace placeholders
|
||||||
|
sed -i "s|CWS|8082|g" "${NGINX_CONFIG}"
|
||||||
|
sed -i "s|REPLACE_HOME|${HOME:-/root}|g" "${NGINX_CONFIG}"
|
||||||
|
|
||||||
# Enable ingress
|
# Enable ingress
|
||||||
cp /etc/nginx/sites-available/ingress.conf /etc/nginx/sites-enabled
|
cp /etc/nginx/sites-available/ingress.conf /etc/nginx/sites-enabled
|
||||||
|
|||||||
Reference in New Issue
Block a user