diff --git a/homematic/CHANGELOG.md b/homematic/CHANGELOG.md index 0ba9ff1..885196f 100644 --- a/homematic/CHANGELOG.md +++ b/homematic/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 10.0 + +- Add Ingress support +- Disable external ports per default +- Fix wrong version number +- Speedup start without sleeps + ## 9.9 - Update glibc for armv7 diff --git a/homematic/Dockerfile b/homematic/Dockerfile index d7c0a08..73e2432 100644 --- a/homematic/Dockerfile +++ b/homematic/Dockerfile @@ -9,10 +9,12 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends \ libusb-1.0 \ lighttpd \ + nginx \ openjdk-11-jre-headless \ && rm -rf /var/lib/apt/lists/* ARG OCCU_VERSION +ARG CCU_VERSION ARG BUILD_ARCH # Install OCCU @@ -27,7 +29,7 @@ RUN curl -SL https://github.com/jens-maus/occu/archive/${OCCU_VERSION}.tar.gz | /opt/HMServer \ /var/status \ \ - && echo "VERSION=${OCCU_VERSION}" > /boot/VERSION \ + && echo "VERSION=${CCU_VERSION}" > /boot/VERSION \ && cp /boot/VERSION /VERSION \ && ln -s /opt/hm/etc/config /etc/config \ \ @@ -62,7 +64,7 @@ RUN curl -SL https://github.com/jens-maus/occu/archive/${OCCU_VERSION}.tar.gz | && cp -R HMserver/opt/HMServer/measurement /opt/HMServer/ \ && cp -R HMserver/opt/HMServer/pages /opt/HMServer/ \ \ - && sed -i "s/WEBUI_VERSION = \".*\"/WEBUI_VERSION = \"${OCCU_VERSION}\"/" WebUI/www/rega/pages/index.htm \ + && sed -i "s/WEBUI_VERSION = \".*\"/WEBUI_VERSION = \"${CCU_VERSION}\"/" WebUI/www/rega/pages/index.htm \ && cp -R WebUI/* / \ && ln -s /www /opt/hm/www \ \ @@ -76,6 +78,7 @@ ENV HM_HOME=/opt/hm LD_LIBRARY_PATH=/opt/hm/lib:${LD_LIBRARY_PATH} # Update config files COPY data/config/* /opt/hm/etc/config/ +COPY data/nginx.conf /etc/nginx/nginx.conf # Setup start script COPY data/run.sh / diff --git a/homematic/build.json b/homematic/build.json index acf8044..6a0d93a 100644 --- a/homematic/build.json +++ b/homematic/build.json @@ -4,6 +4,7 @@ "i386": "homeassistant/i386-base-debian:bullseye" }, "args": { - "OCCU_VERSION": "3.51.6-1" + "OCCU_VERSION": "3.51.6-1", + "CCU_VERSION": "3.51.6" } } diff --git a/homematic/config.json b/homematic/config.json index c82e2c0..173058c 100644 --- a/homematic/config.json +++ b/homematic/config.json @@ -1,6 +1,6 @@ { "name": "HomeMatic CCU", - "version": "9.9", + "version": "10.0", "slug": "homematic", "description": "HomeMatic central based on OCCU", "url": "https://github.com/home-assistant/hassio-addons/tree/master/homematic", @@ -11,18 +11,20 @@ "auto_uart": true, "gpio": true, "apparmor": false, - "webui": "http://[HOST]:[PORT:80]/", + "ingress": true, + "panel_title": "HomeMatic", + "panel_icon": "mdi:router-wireless", "ports": { "80/tcp": null, - "2001/tcp": 2001, - "2000/tcp": 2000, - "2010/tcp": 2010 + "2001/tcp": null, + "2000/tcp": null, + "2010/tcp": null }, "ports_description": { - "80/tcp": "ReGaHss Webinterface", - "2001/tcp": "Homematic xmlrpc", - "2000/tcp": "HomematicWire xmlrpc", - "2010/tcp": "HomematicIP xmlrpc" + "80/tcp": "ReGaHss Webinterface (Not required for Ingress)", + "2001/tcp": "Homematic xmlrpc (Extern)", + "2000/tcp": "HomematicWire xmlrpc (Extern)", + "2010/tcp": "HomematicIP xmlrpc (Extern)" }, "options": { "rf_enable": false, diff --git a/homematic/data/nginx.conf b/homematic/data/nginx.conf new file mode 100644 index 0000000..0a75181 --- /dev/null +++ b/homematic/data/nginx.conf @@ -0,0 +1,73 @@ +worker_processes 1; +pid /var/run/nginx.pid; +error_log /dev/stdout info; +daemon off; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + proxy_read_timeout 1200; + gzip on; + gzip_disable "msie6"; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + # Ingress + server { + listen 8099 default_server; + + allow 172.30.32.2; + deny all; + + server_name _; + access_log /dev/stdout combined; + + client_max_body_size 4G; + keepalive_timeout 5; + + root /dev/null; + + location / { + proxy_pass http://127.0.0.1:80; + proxy_redirect ~^/(.+)$ $scheme://$http_host%%INGRESS_ENTRY%%/$1; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + + 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 Host $http_host; + proxy_set_header X-NginX-Proxy true; + + sub_filter_once off; + sub_filter_types *; + + # Hack for reset paths back + sub_filter '/etc/config/' '/etc/config/'; + + # Make URLs relative + sub_filter '/webui/' '%%INGRESS_ENTRY%%/webui/'; + sub_filter '/ise/' '%%INGRESS_ENTRY%%/ise/'; + sub_filter '/pda/' '%%INGRESS_ENTRY%%/pda/'; + sub_filter '/config/' '%%INGRESS_ENTRY%%/config/'; + sub_filter '/api/' '%%INGRESS_ENTRY%%/api/'; + sub_filter '/pages/' '%%INGRESS_ENTRY%%/pages/'; + sub_filter '/jpages/' '%%INGRESS_ENTRY%%/jpages/'; + sub_filter '/esp/' '%%INGRESS_ENTRY%%/esp/'; + + # Protect iframe breakouts + sub_filter 'top.window.location.href' 'location.href'; + } + } +} \ No newline at end of file diff --git a/homematic/data/run.sh b/homematic/data/run.sh index ed994f5..3e6afbb 100755 --- a/homematic/data/run.sh +++ b/homematic/data/run.sh @@ -140,7 +140,7 @@ function stop_homematic() { trap "stop_homematic" SIGTERM SIGHUP # Wait until interfaces are initialized -sleep 30 +bashio::net.wait_for 9292 # Start Regahss "$HM_HOME/bin/ReGaHss" -c -f /etc/config/rega.conf & @@ -151,6 +151,13 @@ openssl req -new -x509 -nodes -keyout /etc/config/server.pem -out /etc/config/se lighttpd-angel -D -f /opt/hm/etc/lighttpd/lighttpd.conf & WAIT_PIDS+=($!) +# Start Ingress +bashio::log.info "Starting Nginx..." +ingress_entry=$(bashio::addon.ingress_entry) +sed -i "s#%%INGRESS_ENTRY%%#${ingress_entry}#g" /etc/nginx/nginx.conf +nginx & +WAIT_PIDS+=($!) + # Sync time periodically if bashio::config.true 'rf_enable'; then while true