diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 97eb83f..c9ba66a 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -15,7 +15,7 @@ RUN apt update && \ python3-venv \ python3-dev \ build-essential \ - haproxy \ + nginx \ && \ apt clean diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index d1f5af1..7d906ab 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.6.018" +version: "2022.6.019" slug: "3dprinter-octoprint" description: "New instance of OctoPrint" url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh index 1b33178..22d07ea 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -11,5 +11,5 @@ export ingress_entry=${ingress_entry} tempio \ -conf /data/options.json \ - -template /usr/share/tempio/ingress.cfg \ - -out /etc/haproxy/haproxy.cfg + -template /usr/share/tempio/ingress.conf \ + -out /etc/nginx/sites-enabled/ingress.conf diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.cfg b/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.cfg deleted file mode 100644 index 748aa78..0000000 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.cfg +++ /dev/null @@ -1,37 +0,0 @@ -global - maxconn 4096 - user haproxy - group haproxy - daemon - log 127.0.0.1 local0 debug - -defaults - log global - mode http - compression algo gzip - option httplog - option dontlognull - retries 3 - option redispatch - option http-server-close - option forwardfor - maxconn 2000 - timeout connect 5s - timeout client 15m - timeout server 15m - -frontend ingress - bind *:8099 - http-request set-header X-Script-Name {{ env "ingress_entry" }} - default_backend octoprint - -backend octoprint - acl needs_scheme req.hdr_cnt(X-Scheme) eq 0 - - http-request set-header X-Forwarded-Proto https if { ssl_fc } - http-request set-header X-Forwarded-Proto http if !{ ssl_fc } - - option forwardfor - - server octoprint1 127.0.0.1:5000 - errorfile 503 /etc/haproxy/errors/503.http diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.conf b/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.conf new file mode 100644 index 0000000..6c6ae0a --- /dev/null +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.conf @@ -0,0 +1,54 @@ +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + upstream "octoprint" { + server 127.0.0.1:5000; + } + + upstream "mjpg-streamer" { + server 127.0.0.1:8080; + } + + server { + listen 8099; + server_name localhost; + + location /octoprint/ { + proxy_pass http://octoprint/; # make sure to add trailing slash here! + proxy_set_header Host $http_host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header 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-Scheme $scheme; + proxy_set_header X-Script-Name {{ env "ingress_entry" }}; + proxy_http_version 1.1; + + client_max_body_size 0; + } + + location /webcam/ { + proxy_pass http://mjpg-streamer/; + } + + # redirect server error pages to the static page /50x.html + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } +} + + diff --git a/3dprinter-octoprint/translations/en.yaml b/3dprinter-octoprint/translations/en.yaml index 70de024..80921a0 100644 --- a/3dprinter-octoprint/translations/en.yaml +++ b/3dprinter-octoprint/translations/en.yaml @@ -2,3 +2,5 @@ configuration: message: name: Message description: The message that will be printed to the log when starting this example add-on. +network: + 5000/TCP: OctoPrint port (not used for Ingress) \ No newline at end of file