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

@@ -1,22 +1,9 @@
- Addition of ingress
## 25.1.11 (12-01-2025)
- Moving 99-run.sh to cont-init.d
## 25.1.9 (12-01-2025)
- Minor bugs fixed
## 25.1.8.9 (11-01-2025)
- Docs, symlink test
## 25.1.8 (11-01-2025)
- Update to latest version from jokob-sk/NetAlertX (changelog : https://github.com/jokob-sk/NetAlertX/releases)
## 0.0.8 (10-01-2025)
- Minor bugs fixed
## 0.0.7
- re-add oneshot type

View File

@@ -72,6 +72,8 @@
"host_network": true,
"image": "ghcr.io/alexbelgium/netalertx-{arch}",
"init": false,
"ingress": true,
"ingress_port": 0,
"map": [
"addon_config:rw",
"media:rw",
@@ -83,6 +85,7 @@
"PGID": 0,
"PUID": 0
},
"panel_icon": "mdi:wifi-check",
"ports": {
"20211/tcp": 20211,
"20212/tcp": 20212
@@ -104,6 +107,5 @@
"slug": "netalertx",
"udev": true,
"url": "https://github.com/alexbelgium/hassio-addons",
"version": "25.1.11",
"webui": "[PROTO:ssl]://[HOST]:[PORT:20211]"
"version": "25.1.12"
}

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';
}
}