diff --git a/README.md b/README.md index c3eb41d..9da5799 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,17 @@ # Home Assistant Add-On repository (by Max Winterstein) +*Everything here is ment to be **experimental**. Happy to see feedback!* + Home Assistant Addon repository containing ## Eufy Home Assistant MQTT Bridge ([matijse/eufy-ha-mqtt-bridge](https://github.com/matijse/eufy-ha-mqtt-bridge)) -Forwards Eufy Security push notifications to Home Assistant via MQTT. **Experimental** +Forwards Eufy Security push notifications to Home Assistant via MQTT. ## ioBroker ([iobroker.net](http://iobroker.net)) -Run ioBroker as Add-on. **Experimental** +Run ioBroker as Add-on. + +## OctoPrint Reverse Proxy ([octoprint.org](http://octoprint.org)) +Small proxy to add OctoPrint to the Home Assistant. ## Installation Go to the *Supervisor* Panel, select *Add-on Store*, click the three little dots on the upper right and select *Repositories*. Now fill the *Add repository* testbox with `https://github.com/MaxWinterstein/homeassistant-addons/` and click *Add*. diff --git a/octoprint-proxy/CHANGELOG.md b/octoprint-proxy/CHANGELOG.md new file mode 100644 index 0000000..faea141 --- /dev/null +++ b/octoprint-proxy/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog + +## [1.0.0] - 2021-01-03 +- Initial release \ No newline at end of file diff --git a/octoprint-proxy/Dockerfile b/octoprint-proxy/Dockerfile new file mode 100644 index 0000000..a02f849 --- /dev/null +++ b/octoprint-proxy/Dockerfile @@ -0,0 +1,11 @@ +ARG BUILD_FROM +FROM $BUILD_FROM + +ENV LANG C.UTF-8 + +RUN apk add haproxy + +COPY run.sh haproxy.cfg / + +RUN chmod a+x /run.sh +CMD [ "/run.sh" ] \ No newline at end of file diff --git a/octoprint-proxy/README.md b/octoprint-proxy/README.md new file mode 100644 index 0000000..07e7500 --- /dev/null +++ b/octoprint-proxy/README.md @@ -0,0 +1,7 @@ +# Home Assistant Add-on: OctoPrint Proxy + +Small *haproxy* based reverse proxy to have OctoPrint accessible from Home Assistant with a memory consumption less than 10Mbyte. + +Works great with OctoPi based installations, others not tested. Feedback welcome. + +**Remember to enable the *Show in sidebar* option.** \ No newline at end of file diff --git a/octoprint-proxy/config.json b/octoprint-proxy/config.json new file mode 100644 index 0000000..3bf83db --- /dev/null +++ b/octoprint-proxy/config.json @@ -0,0 +1,37 @@ +{ + "name": "OctoPrint Proxy", + "version": "1.0.0", + "slug": "octoprint_proxy", + "description": "Access OctoPrint from within Home Assistant", + "url": "https://github.com/MaxWinterstein/homeassistant-addons/", + "ingress": true, + "ingress_port": 80, + "panel_title": "OctoPrint", + "panel_icon": "mdi:printer-3d-nozzle", + "arch": [ + "armhf", + "armv7", + "aarch64", + "amd64", + "i386" + ], + "startup": "application", + "boot": "auto", + "options": { + "octoprint_host" : "octopi", + "octoprint_port" : "443", + "ssl": { + "enabled": true, + "verify": false + } + }, + "schema": { + "octoprint_host" : "str", + "octoprint_port" : "port", + "ssl": { + "enabled": "bool", + "verify": "bool" + } + }, + "hassio_api": false +} \ No newline at end of file diff --git a/octoprint-proxy/haproxy.cfg b/octoprint-proxy/haproxy.cfg new file mode 100644 index 0000000..436c836 --- /dev/null +++ b/octoprint-proxy/haproxy.cfg @@ -0,0 +1,52 @@ +global + log stdout format raw local0 + + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + daemon + + # turn on stats unix socket + stats socket /var/lib/haproxy/stats + +#--------------------------------------------------------------------- +# common defaults that all the 'listen' and 'backend' sections will +# use if not designated in their block +#--------------------------------------------------------------------- +defaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +#--------------------------------------------------------------------- +# main frontend which proxys to the backends +#--------------------------------------------------------------------- +frontend main + mode http + option httplog + #capture request header X-Ingress-Path len 256 + + bind *:80 + default_backend octoprint + +backend octoprint + # ref https://community.octoprint.org/t/reverse-proxy-configuration-examples/ + http-request replace-path ^([^\ :]*)\ /local_octoprint_proxy/(.*) \1\ /\2 + http-request add-header X-Script-Name %[req.hdr(X-Ingress-Path)] + option forwardfor + server octoprint OCTOPRINT_HOST:OCTOPRINT_PORT USE_SSL VERIFY_SSL check diff --git a/octoprint-proxy/icon.png b/octoprint-proxy/icon.png new file mode 100644 index 0000000..a8ce6fb Binary files /dev/null and b/octoprint-proxy/icon.png differ diff --git a/octoprint-proxy/logo.png b/octoprint-proxy/logo.png new file mode 100644 index 0000000..d45d4c8 Binary files /dev/null and b/octoprint-proxy/logo.png differ diff --git a/octoprint-proxy/run.sh b/octoprint-proxy/run.sh new file mode 100644 index 0000000..1f92181 --- /dev/null +++ b/octoprint-proxy/run.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bashio +set -e + +bashio::log.info "Setting octoprint host: $(bashio::config octoprint_host)" +sed -i "s/OCTOPRINT_HOST/$(bashio::config octoprint_host)/g" /haproxy.cfg + +bashio::log.info "Setting octoprint port: $(bashio::config octoprint_port)" +sed -i "s/OCTOPRINT_PORT/$(bashio::config octoprint_port)/g" /haproxy.cfg + +if $(bashio::config.true ssl.enabled); then + bashio::log.info "SSL communitcation to octoprint enabled" + sed -i "s/USE_SSL/ssl/g" /haproxy.cfg + + if $(bashio::config.true ssl.verify); then + bashio::log.info "SSL verification enabled" + sed -i "s/VERIFY_SSL//g" /haproxy.cfg + else + bashio::log.info "SSL verification disabled" + sed -i "s/VERIFY_SSL/verify none/g" /haproxy.cfg + fi + +else + bashio::log.info "SSL communitcation to octoprint not enabled" + sed -i "s/USE_SSL VERIFY_SSL//g" /haproxy.cfg +fi + +bashio::log.info "Server line: $(cat /haproxy.cfg | grep 'server octoprint')" + +bashio::log.info "Starting haproxy" +haproxy -W -db -f /haproxy.cfg \ No newline at end of file