Add ingress

This commit is contained in:
Alexandre
2025-01-14 12:12:00 +01:00
parent a844f787b9
commit 53aae2d105
5 changed files with 57 additions and 26 deletions

View File

@@ -0,0 +1,19 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
#################
# NGINX SETTING #
#################
declare ingress_interface
declare ingress_port
declare ingress_entry
echo "Adapting for ingress"
ingress_port=$(bashio::addon.ingress_port)
ingress_interface=$(bashio::addon.ip_address)
ingress_entry=$(bashio::addon.ingress_entry)
sed -i "s|%%port%%|${ingress_port}|g" /etc/nginx/http.d/ingress.conf
sed -i "s|%%interface%%|${ingress_interface}|g" /etc/nginx/http.d/ingress.conf
sed -i "s|%%ingress_entry%%|${ingress_entry}|g" /etc/nginx/http.d/ingress.conf

View File

@@ -4,8 +4,6 @@ set -e
bashio::log.warning "App starting."
# In the addon script, make symlinks on the fly
echo "Creating symlinks"
for folder in config db; do
@@ -24,10 +22,3 @@ sudo chown -R nginx:www-data /config/config/
if [ -f /config/db/app.db ]; then
chmod a+rwx /config/db/app.db
fi
##############
# LAUNCH APP #
##############
#chmod +x /app/dockerfiles/start.sh
#/app/dockerfiles/start.sh

View File

@@ -0,0 +1,32 @@
server {
listen %%interface%%:%%port%% default_server;
server_name netalertx;
location / {
proxy_pass http://localhost:20211/;
proxy_redirect ~^/(.*)$ %%ingress_entry%%/$1;
rewrite ^%%ingress_entry%%/?(.*)$ /$1 break;
sub_filter_once off;
sub_filter_types *;
sub_filter 'href="/' 'href="%%ingress_entry%%/';
sub_filter '(?>$host)/css' '%%ingress_entry%%/css';
sub_filter '(?>$host)/js' '%%ingress_entry%%/js';
sub_filter '/img' '%%ingress_entry%%/img';
sub_filter '/lib' '%%ingress_entry%%/lib';
sub_filter '/php' '%%ingress_entry%%/php';
# Next three lines allow websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Improve ip handling
proxy_hide_header X-Powered-By;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Accept-Encoding "";
proxy_read_timeout 90;
add_header X-Frame-Options "SAMEORIGIN";
add_header 'Referrer-Policy' 'no-referrer';
}
}