From 388caed235a8d1c60c89959cbf4828e7379841b9 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 16:23:59 +0200 Subject: [PATCH 01/78] Updates to Ingress, use local image --- 3dprinter-octoprint/config.yaml | 1 - 3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh | 1 + 3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl | 2 +- 3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish | 4 ++-- 3dprinter-octoprint/rootfs/etc/services.d/octoprint/run | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index ac27a25..bf650a8 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -27,5 +27,4 @@ options: recovery: false schema: recovery: "bool" -image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} tmpfs: true diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh index abbf207..8d0a0f4 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh @@ -16,6 +16,7 @@ bashio::var.json \ # Generate direct access configuration, if enabled. if bashio::var.has_value "$(bashio::addon.port 80)"; then bashio::var.json \ + interface "$(bashio::addon.ip_address)" \ port "^$(bashio::addon.port 80)" \ | tempio \ -template /etc/nginx/templates/direct.gtpl \ diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index 2fd0020..b501ded 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -1,5 +1,5 @@ server { - listen {{ .port }} default_server; + listen {{ .interface }}:{{ .port }} default_server; include /etc/nginx/includes/server_params.conf; include /etc/nginx/includes/proxy_params.conf; diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish index 1ecc5e9..4cea07a 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish @@ -1,7 +1,7 @@ #!/usr/bin/execlineb -S0 # ============================================================================== -# Add-on: mjpg-streamer -# Take down the S6 supervision tree when mjpg-streamer fails +# Add-on: 3dprinter-octoprint +# Take down the S6 supervision tree when OctoPrint fails # ============================================================================== if -n { s6-test $# -ne 0 } if -n { s6-test ${1} -eq 256 } diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run index bbdf675..c150721 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run @@ -5,4 +5,4 @@ # ============================================================================== ## Run your program -exec octoprint serve --iknowwhatimdoing --host 0.0.0.0 --port 5000 --basedir /data/config/octoprint +exec octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 5000 --basedir /data/config/octoprint --debug From d9ee5ccaca6acfa7da6dd713fad326d067d27171 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 16:33:23 +0200 Subject: [PATCH 02/78] Remove max size; add X-Scheme --- 3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf | 2 ++ 3dprinter-octoprint/rootfs/etc/nginx/nginx.conf | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf b/3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf index 1990d49..406b739 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf +++ b/3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf @@ -13,3 +13,5 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-NginX-Proxy true; proxy_set_header X-Real-IP $remote_addr; + +proxy_set_header X-Scheme $scheme; \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf index 11e15c7..e496e8b 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf +++ b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf @@ -25,7 +25,7 @@ http { include /etc/nginx/includes/mime.types; access_log off; - client_max_body_size 4G; + client_max_body_size 0; default_type application/octet-stream; gzip on; keepalive_timeout 65; From 3dc492ebf6427b36f31521a7596af1a77060878d Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 16:35:00 +0200 Subject: [PATCH 03/78] Update version number --- 3dprinter-octoprint/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index bf650a8..fcc184a 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.005" +version: "2022.7.006" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From cc65035aebf875c3100207e34428b63e8448e0c7 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 17:02:25 +0200 Subject: [PATCH 04/78] Use port 5000 --- 3dprinter-octoprint/config.yaml | 6 +++--- 3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index fcc184a..c5f1cce 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.006" +version: "2022.7.007" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -20,9 +20,9 @@ gpio: true uart: true usb: true ports: - 80/tcp: null + 5000/tcp: null ports_description: - 80/tcp: Web-based interface (Not required for Ingress) + 5000/tcp: Web-based interface (Not required for Ingress) options: recovery: false schema: diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh index 8d0a0f4..2d0d6c2 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh @@ -14,10 +14,10 @@ bashio::var.json \ -out /etc/nginx/servers/ingress.conf # Generate direct access configuration, if enabled. -if bashio::var.has_value "$(bashio::addon.port 80)"; then +if bashio::var.has_value "$(bashio::addon.port 5000)"; then bashio::var.json \ interface "$(bashio::addon.ip_address)" \ - port "^$(bashio::addon.port 80)" \ + port "^$(bashio::addon.port 5000)" \ | tempio \ -template /etc/nginx/templates/direct.gtpl \ -out /etc/nginx/servers/direct.conf From 5c11796c88cf5e8ede899b9f64c7aecb7a8652e8 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 17:08:33 +0200 Subject: [PATCH 05/78] Add X-Forward-For --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index c5f1cce..d629837 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.007" +version: "2022.7.008" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 5bb5879..38dadd1 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -10,5 +10,6 @@ server { proxy_pass http://backend; proxy_set_header X-Script-Name {{ .ingress_entry }}; + add_header X-Forwarded-For 172.30.32.2 } } From eb97ecd770990657b47d0b4363f8c93fd98c7313 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 17:44:51 +0200 Subject: [PATCH 06/78] Add nginx headers directly to template --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/templates/ingress.gtpl | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index d629837..8da6a44 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.008" +version: "2022.7.009" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 38dadd1..e3e89c6 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -9,7 +9,18 @@ server { deny all; proxy_pass http://backend; + 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 {{ .ingress_entry }}; - add_header X-Forwarded-For 172.30.32.2 + proxy_http_version 1.1; + + client_max_body_size 0; + + proxy_set_header X-Forwarded-For 172.30.32.2; + add_header Origin 172.30.32.2; } } From 3441ebebb064de805953917b248b4d56eadf815e Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 17:47:02 +0200 Subject: [PATCH 07/78] Add missing backslash --- 3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index b501ded..542e396 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -5,6 +5,6 @@ server { include /etc/nginx/includes/proxy_params.conf; location / { - proxy_pass http://backend; + proxy_pass http://backend/; } } diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index e3e89c6..1e38fc9 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -8,7 +8,7 @@ server { allow 172.30.32.2; deny all; - proxy_pass http://backend; + proxy_pass http://backend/; proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; From a6f65d33e3b633294cabb706eb6418e712de8a42 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 17:49:13 +0200 Subject: [PATCH 08/78] Update version number --- 3dprinter-octoprint/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 8da6a44..f0cb8f2 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.009" +version: "2022.7.010" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From 2b4c5c97c779f0592a18dfe6de9c1a385f0006c9 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 18:05:58 +0200 Subject: [PATCH 09/78] attempt to bypass https issue --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/templates/ingress.gtpl | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index f0cb8f2..92475fd 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.010" +version: "2022.7.012" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 1e38fc9..b695a97 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -1,8 +1,8 @@ server { listen {{ .interface }}:{{ .port }} default_server; - include /etc/nginx/includes/server_params.conf; - include /etc/nginx/includes/proxy_params.conf; + # include /etc/nginx/includes/server_params.conf; + # include /etc/nginx/includes/proxy_params.conf; location / { allow 172.30.32.2; @@ -22,5 +22,8 @@ server { proxy_set_header X-Forwarded-For 172.30.32.2; add_header Origin 172.30.32.2; + + # Required when mixing http and https? + add_header Access-Control-Allow-Origin *; } } From 8f7ca834385c1ad23cbd0d2cde1b58fdaebb34de Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 18:45:00 +0200 Subject: [PATCH 10/78] Revert parts of nginx config --- 3dprinter-octoprint/config.yaml | 3 ++- .../rootfs/etc/nginx/templates/ingress.gtpl | 19 +++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 92475fd..3c37f88 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.012" +version: "2022.7.013" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -27,4 +27,5 @@ options: recovery: false schema: recovery: "bool" +image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} tmpfs: true diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index b695a97..cbdc3a9 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -1,29 +1,16 @@ server { listen {{ .interface }}:{{ .port }} default_server; - # include /etc/nginx/includes/server_params.conf; - # include /etc/nginx/includes/proxy_params.conf; + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; location / { allow 172.30.32.2; deny all; proxy_pass http://backend/; - 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 {{ .ingress_entry }}; - proxy_http_version 1.1; - - client_max_body_size 0; - proxy_set_header X-Forwarded-For 172.30.32.2; - add_header Origin 172.30.32.2; - - # Required when mixing http and https? - add_header Access-Control-Allow-Origin *; + proxy_set_header Origin 172.30.32.2; } } From 225524894b027b8b7fb022b6636c3d42fd460c22 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 19:04:45 +0200 Subject: [PATCH 11/78] Include nginx params in http block --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/nginx.conf | 3 +++ 3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl | 3 --- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 3 --- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 3c37f88..d578558 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.013" +version: "2022.7.014" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf index e496e8b..86a8eb1 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf +++ b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf @@ -39,6 +39,9 @@ http { '' close; } + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + include /etc/nginx/includes/upstream.conf; include /etc/nginx/servers/*.conf; } diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index 542e396..1ddcd17 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -1,9 +1,6 @@ server { listen {{ .interface }}:{{ .port }} default_server; - include /etc/nginx/includes/server_params.conf; - include /etc/nginx/includes/proxy_params.conf; - location / { proxy_pass http://backend/; } diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index cbdc3a9..915709f 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -1,9 +1,6 @@ server { listen {{ .interface }}:{{ .port }} default_server; - include /etc/nginx/includes/server_params.conf; - include /etc/nginx/includes/proxy_params.conf; - location / { allow 172.30.32.2; deny all; From 9a0dc3966948735629e440f5e7dd2bbb846c1b42 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 19:16:11 +0200 Subject: [PATCH 12/78] Add lines according to OctoPrint reverse proxy --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/includes/upstream.conf | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/nginx.conf | 3 --- .../rootfs/etc/nginx/templates/direct.gtpl | 5 ++++- .../rootfs/etc/nginx/templates/ingress.gtpl | 17 +++++++++++++++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index d578558..2b234f8 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.014" +version: "2022.7.015" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/includes/upstream.conf b/3dprinter-octoprint/rootfs/etc/nginx/includes/upstream.conf index 3252455..a660320 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/includes/upstream.conf +++ b/3dprinter-octoprint/rootfs/etc/nginx/includes/upstream.conf @@ -1,3 +1,3 @@ -upstream backend { +upstream octoprint { server 127.0.0.1:5000; } diff --git a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf index 86a8eb1..e496e8b 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf +++ b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf @@ -39,9 +39,6 @@ http { '' close; } - include /etc/nginx/includes/server_params.conf; - include /etc/nginx/includes/proxy_params.conf; - include /etc/nginx/includes/upstream.conf; include /etc/nginx/servers/*.conf; } diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index 1ddcd17..7e27118 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -1,7 +1,10 @@ server { listen {{ .interface }}:{{ .port }} default_server; + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + location / { - proxy_pass http://backend/; + proxy_pass http://octoprint/; } } diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 915709f..7c1a731 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -1,12 +1,25 @@ server { listen {{ .interface }}:{{ .port }} default_server; + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + location / { allow 172.30.32.2; deny all; - - proxy_pass http://backend/; + + 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 {{ .ingress_entry }}; + proxy_http_version 1.1; + + client_max_body_size 0; + proxy_set_header X-Forwarded-For 172.30.32.2; proxy_set_header Origin 172.30.32.2; } From 6b5dfc5fe63c976918827eba3b4453af195cfe79 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 19:25:58 +0200 Subject: [PATCH 13/78] Updates for proxy --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 6 +++--- .../rootfs/root/config/octoprint/config.yaml | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 2b234f8..677a260 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.015" +version: "2022.7.016" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 7c1a731..e83d0a8 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -7,6 +7,9 @@ server { location / { allow 172.30.32.2; deny all; + + proxy_set_header X-Forwarded-For 172.30.32.2; + proxy_set_header Origin 172.30.32.2; proxy_pass http://octoprint/; # make sure to add trailing slash here! proxy_set_header Host $http_host; @@ -19,8 +22,5 @@ server { proxy_http_version 1.1; client_max_body_size 0; - - proxy_set_header X-Forwarded-For 172.30.32.2; - proxy_set_header Origin 172.30.32.2; } } diff --git a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml index a0d89c6..aa912cb 100644 --- a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml +++ b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml @@ -2,6 +2,8 @@ accessControl: autologinAs: homeassistant autologinLocal: true localNetworks: + - 127.0.0.0/8 + - ::1/128 - 172.30.32.2 folder: generated: /tmp/octoprint/generated From ec2eb141a8a5a8d55eeaf64e6538f712fb5a5339 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 19:34:37 +0200 Subject: [PATCH 14/78] Remove upstream alias from Ingress --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 2 +- 3dprinter-octoprint/rootfs/etc/services.d/octoprint/run | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 677a260..0ef06ad 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.016" +version: "2022.7.017" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index e83d0a8..06ea5a4 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -11,7 +11,7 @@ server { proxy_set_header X-Forwarded-For 172.30.32.2; proxy_set_header Origin 172.30.32.2; - proxy_pass http://octoprint/; # make sure to add trailing slash here! + proxy_pass http://127.0.0.1:5000/; # make sure to add trailing slash here! proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run index c150721..5f63fc5 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run @@ -5,4 +5,4 @@ # ============================================================================== ## Run your program -exec octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 5000 --basedir /data/config/octoprint --debug +exec octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 5000 --basedir /data/config/octoprint From 48d53263fb8dc6b99329f66f9b1b4012d0c125ce Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 19:44:10 +0200 Subject: [PATCH 15/78] Rename 3dprinter-octoprint to 3dprinter-op --- 3dprinter-octoprint/README.md | 2 +- 3dprinter-octoprint/config.yaml | 10 +++++----- .../rootfs/etc/cont-init.d/octoprint.sh | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/3dprinter-octoprint/README.md b/3dprinter-octoprint/README.md index 1148f6c..c1e0c6d 100644 --- a/3dprinter-octoprint/README.md +++ b/3dprinter-octoprint/README.md @@ -1,3 +1,3 @@ -# 3DPrinter-OctoPrint +# 3DPrinter-OP Provides OctoPrint as an addon to Home Assistant. diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 0ef06ad..28214bd 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,12 +1,12 @@ -name: "3DPrinter-OctoPrint" -version: "2022.7.017" -slug: "3dprinter-octoprint" +name: "3DPrinter-OP" +version: "2022.7.018" +slug: "3dprinter-op" description: "OctoPrint as an addon, no additional bells and whistles." -url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" +url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-op" ingress: true ingress_stream: true panel_icon: mdi:printer-3d -panel_title: 3DPrinter-OctoPrint +panel_title: 3DPrinter-OP arch: - armv7 - amd64 diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index 379de02..b3f31cd 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -11,6 +11,8 @@ python --version } || { # Otherwise create Python virtual environment. python3 -m venv /data/python/octoprint + # Install wheel to speed up future installs. + pip install wheel } pip install octoprint==$OCTOPRINT_VERSION } From d7e82f132b530966fe76796ef928c162f9151dca Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 19:46:00 +0200 Subject: [PATCH 16/78] Revert namechange --- 3dprinter-octoprint/README.md | 2 +- 3dprinter-octoprint/config.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/3dprinter-octoprint/README.md b/3dprinter-octoprint/README.md index c1e0c6d..1148f6c 100644 --- a/3dprinter-octoprint/README.md +++ b/3dprinter-octoprint/README.md @@ -1,3 +1,3 @@ -# 3DPrinter-OP +# 3DPrinter-OctoPrint Provides OctoPrint as an addon to Home Assistant. diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 28214bd..7e1828c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,12 +1,12 @@ -name: "3DPrinter-OP" +name: "3DPrinter-OctoPrint" version: "2022.7.018" -slug: "3dprinter-op" +slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." -url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-op" +url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" ingress: true ingress_stream: true panel_icon: mdi:printer-3d -panel_title: 3DPrinter-OP +panel_title: 3DPrinter-OctoPrint arch: - armv7 - amd64 From 35d82905aa7dcd6f985da99700da3ad56f944207 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 22:46:43 +0200 Subject: [PATCH 17/78] Add scripts for shutdown and restart --- 3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh | 5 +++++ 3dprinter-octoprint/rootfs/scripts/system_restart.sh | 3 +++ 3dprinter-octoprint/rootfs/scripts/system_shutdown.sh | 3 +++ 3 files changed, 11 insertions(+) create mode 100644 3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh create mode 100644 3dprinter-octoprint/rootfs/scripts/system_restart.sh create mode 100644 3dprinter-octoprint/rootfs/scripts/system_shutdown.sh diff --git a/3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh b/3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh new file mode 100644 index 0000000..874f9a4 --- /dev/null +++ b/3dprinter-octoprint/rootfs/scripts/octoprint_restart.sh @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +bashio::log.warning "Restart OctoPrint." + +s6-svc -r /var/run/s6/legacy-services/octoprint diff --git a/3dprinter-octoprint/rootfs/scripts/system_restart.sh b/3dprinter-octoprint/rootfs/scripts/system_restart.sh new file mode 100644 index 0000000..3d1c575 --- /dev/null +++ b/3dprinter-octoprint/rootfs/scripts/system_restart.sh @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bashio + +bashio::addon.restart diff --git a/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh b/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh new file mode 100644 index 0000000..064679e --- /dev/null +++ b/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bashio + +bashio::addon.stop From 6b24d3798ce5e0db5e2624e23c738826d6fb72a4 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 22:47:00 +0200 Subject: [PATCH 18/78] Enable CORS --- 3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml index aa912cb..2abcc01 100644 --- a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml +++ b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml @@ -5,6 +5,8 @@ accessControl: - 127.0.0.0/8 - ::1/128 - 172.30.32.2 +api: + allowCrossOrigin: true folder: generated: /tmp/octoprint/generated timelapse_tmp: /tmp/octoprint/timelapse/tmp From 8b520461337f5f541253a9f8f5135ffd36b92191 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 22:47:07 +0200 Subject: [PATCH 19/78] Update version number --- 3dprinter-octoprint/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 7e1828c..8a6ce24 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.018" +version: "2022.7.019" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From 1012a52afacf543e066cf1f37075154ef67cfb20 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 23:02:37 +0200 Subject: [PATCH 20/78] Make scripts executable --- 3dprinter-octoprint/Dockerfile | 1 + 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/scripts/system_restart.sh | 2 ++ 3dprinter-octoprint/rootfs/scripts/system_shutdown.sh | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 563de9c..628565d 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -24,3 +24,4 @@ RUN apt update && \ COPY rootfs / RUN chmod +x /etc/cont-init.d/*.sh RUN chmod +x /etc/services.d/*/* +RUN chmod +x /scripts/*.sh diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 8a6ce24..af31209 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.019" +version: "2022.7.020" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/scripts/system_restart.sh b/3dprinter-octoprint/rootfs/scripts/system_restart.sh index 3d1c575..a224d4d 100644 --- a/3dprinter-octoprint/rootfs/scripts/system_restart.sh +++ b/3dprinter-octoprint/rootfs/scripts/system_restart.sh @@ -1,3 +1,5 @@ #!/usr/bin/with-contenv bashio +bashio::log.warning "Restart addon." + bashio::addon.restart diff --git a/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh b/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh index 064679e..59972e3 100644 --- a/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh +++ b/3dprinter-octoprint/rootfs/scripts/system_shutdown.sh @@ -1,3 +1,5 @@ #!/usr/bin/with-contenv bashio +bashio::log.warning "Shutdown addon." + bashio::addon.stop From 67f7dcf9fbc5a5431513bc02c0ca5d3a1182fd75 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 23:36:01 +0200 Subject: [PATCH 21/78] Add config for camera --- 3dprinter-octoprint/config.yaml | 4 +++- .../rootfs/etc/cont-init.d/nginx.sh | 1 + .../rootfs/etc/nginx/templates/ingress.gtpl | 14 +++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index af31209..2c398f9 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.020" +version: "2022.7.021" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -24,8 +24,10 @@ ports: ports_description: 5000/tcp: Web-based interface (Not required for Ingress) options: + camera_url: "http://b7aa59c4-camera-mjpg-streamer/" recovery: false schema: + camera_url: "url" recovery: "bool" image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} tmpfs: true diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh index 2d0d6c2..f9c3440 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh @@ -9,6 +9,7 @@ bashio::var.json \ interface "$(bashio::addon.ip_address)" \ port "^$(bashio::addon.ingress_port)" \ ingress_entry "$(bashio::addon.ingress_entry)" \ + camera_host "$(bashio::config 'camera_url')" \ | tempio \ -template /etc/nginx/templates/ingress.gtpl \ -out /etc/nginx/servers/ingress.conf diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 06ea5a4..007e83d 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -11,7 +11,7 @@ server { proxy_set_header X-Forwarded-For 172.30.32.2; proxy_set_header Origin 172.30.32.2; - proxy_pass http://127.0.0.1:5000/; # make sure to add trailing slash here! + 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"; @@ -23,4 +23,16 @@ server { client_max_body_size 0; } + + location /webcam/ { + proxy_pass {{ .camera_host }}; + 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_http_version 1.1; + client_max_body_size 0; + } } From d65522a0945322b66edca53774a30f415073b37c Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 23:54:39 +0200 Subject: [PATCH 22/78] Add X-Script-Name for camera --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 2c398f9..93afd44 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.021" +version: "2022.7.022" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 007e83d..ab7610d 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -32,6 +32,7 @@ server { 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 {{ .ingress_entry }}/webcam; proxy_http_version 1.1; client_max_body_size 0; } From b4da47bf41f0be245a8892badedc0a8ade34dc9a Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 12 Jul 2022 01:36:07 +0200 Subject: [PATCH 23/78] Cleanup webcam config --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/templates/ingress.gtpl | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 93afd44..adb0e0d 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.022" +version: "2022.7.023" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index ab7610d..06e7027 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -26,14 +26,5 @@ server { location /webcam/ { proxy_pass {{ .camera_host }}; - 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 {{ .ingress_entry }}/webcam; - proxy_http_version 1.1; - client_max_body_size 0; } } From 92e2307c3524f3892f7137ce3fdf5ba20e74a83b Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 12 Jul 2022 02:07:18 +0200 Subject: [PATCH 24/78] Change to older version of OctoPrint --- 3dprinter-octoprint/Dockerfile | 2 +- 3dprinter-octoprint/config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 628565d..9ae56dc 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,6 +1,6 @@ ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" FROM ${BUILD_FROM} -ARG OCTOPRINT_VERSION="1.8.1" +ARG OCTOPRINT_VERSION="1.7.2" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index adb0e0d..001f95c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.023" +version: "2022.7.024" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From c23bd3726b371ba63c1f4823141abe01607bf594 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 12 Jul 2022 13:32:56 +0200 Subject: [PATCH 25/78] Use latest OctoPrint version; add ffmpeg path to config --- 3dprinter-octoprint/Dockerfile | 9 ++++++++- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/root/config/octoprint/config.yaml | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 9ae56dc..7030e41 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,6 +1,6 @@ ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" FROM ${BUILD_FROM} -ARG OCTOPRINT_VERSION="1.7.2" +ARG OCTOPRINT_VERSION="1.8.1" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} @@ -12,11 +12,18 @@ ENV PATH=/data/python/octoprint/bin:${PATH} # Install dependencies RUN apt update && \ apt install -y \ + --no-install-recommends \ python3-venv \ python3-dev \ python3-wheel \ build-essential \ nginx \ + # Extras. + # ffmpeg \ + # avrdude \ + # dfu-util \ + # dfu-programmer \ + # stm32flash \ && \ apt clean diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 001f95c..14b2192 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.024" +version: "2022.7.025" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml index 2abcc01..a5b1d15 100644 --- a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml +++ b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml @@ -15,3 +15,5 @@ server: serverRestartCommand: /scripts/octoprint_restart.sh systemRestartCommand: /scripts/system_restart.sh systemShutdownCommand: /scripts/system_shutdown.sh +webcam: + ffmpeg: /usr/bin/ffmpeg From ce823c0467df07941270bdfdcab54a6aa4b61e2b Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Fri, 23 Sep 2022 00:33:25 +0200 Subject: [PATCH 26/78] Attempt to update proxy --- 3dprinter-octoprint/Dockerfile | 2 +- 3dprinter-octoprint/build.yaml | 16 +++++------ 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/logo.png | Bin 75254 -> 75254 bytes .../rootfs/etc/nginx/templates/ingress.gtpl | 26 ++++++++++-------- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 7030e41..d718225 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,6 +1,6 @@ ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" FROM ${BUILD_FROM} -ARG OCTOPRINT_VERSION="1.8.1" +ARG OCTOPRINT_VERSION="1.8.3" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 72fafe9..778b554 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -1,12 +1,12 @@ build_from: - aarch64: ghcr.io/home-assistant/aarch64-base-debian:bullseye - amd64: ghcr.io/home-assistant/amd64-base-debian:bullseye - armhf: ghcr.io/home-assistant/armhf-base-debian:bullseye - armv7: ghcr.io/home-assistant/armv7-base-debian:bullseye - i386: ghcr.io/home-assistant/i386-base-debian:bullseye + aarch64: ghcr.io/home-assistant/aarch64-base-debian:bullseye + amd64: ghcr.io/home-assistant/amd64-base-debian:bullseye + armhf: ghcr.io/home-assistant/armhf-base-debian:bullseye + armv7: ghcr.io/home-assistant/armv7-base-debian:bullseye + i386: ghcr.io/home-assistant/i386-base-debian:bullseye labels: - org.opencontainers.image.title: "Home Assistant Add-on: 3DPrinter-OctoPrint add-on" + org.opencontainers.image.title: "Home Assistant Add-on: 3DPrinter-OctoPrint" org.opencontainers.image.description: "3DPrinter-OctoPrint addon for Home-Assistant." - org.opencontainers.image.source: "https://github.com/fredrikbaberg/home-assistant-addons" + org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons" args: - OCTOPRINT_VERSION: "1.8.1" + OCTOPRINT_VERSION: "1.8.3" diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 14b2192..8a9fd39 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.7.025" +version: "2022.9.001" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/logo.png b/3dprinter-octoprint/logo.png index 459e1f20b2bf5f7a1e90b7b46a3fce5934b536d0..8b49f7122664b3478f324b56ca1f0e3e81f184df 100644 GIT binary patch delta 72 xcmex%n&sPRmJPRC*i>ZR0?|ar>di5&nN0km3?0a5qGQEopAPKeHr=~s0RYo#7}@{; delta 49 ucmex%n&sPRmJPRCCK@zuj%m$gnmnhMfAZem{D}dan|(S^`8M6VW&r?bZ5N#Y diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 06e7027..c95587d 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -4,24 +4,26 @@ server { include /etc/nginx/includes/server_params.conf; include /etc/nginx/includes/proxy_params.conf; - location / { + location {{ .ingress_entry }} { allow 172.30.32.2; deny all; - proxy_set_header X-Forwarded-For 172.30.32.2; - proxy_set_header Origin 172.30.32.2; - 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 {{ .ingress_entry }}; + 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 {{ .ingress_entry }}; proxy_http_version 1.1; + client_max_body_size 0; - client_max_body_size 0; + proxy_set_header X-Forwarded-Scheme $scheme; + proxy_set_header X-Forwarded-Proto $scheme; + + # proxy_set_header X-Forwarded-For 172.30.32.2; + # proxy_set_header Origin 172.30.32.2; } location /webcam/ { From a589351f4a67e9baa9dcbb10af0114a568d2d768 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Fri, 23 Sep 2022 00:55:08 +0200 Subject: [PATCH 27/78] revert some proxy config --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 8a9fd39..a44445c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.001" +version: "2022.9.002" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index c95587d..c7854e7 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -4,7 +4,7 @@ server { include /etc/nginx/includes/server_params.conf; include /etc/nginx/includes/proxy_params.conf; - location {{ .ingress_entry }} { + location / { allow 172.30.32.2; deny all; @@ -22,8 +22,8 @@ server { proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; - # proxy_set_header X-Forwarded-For 172.30.32.2; - # proxy_set_header Origin 172.30.32.2; + proxy_set_header X-Forwarded-For 172.30.32.2; + proxy_set_header Origin 172.30.32.2; } location /webcam/ { From 67bb854462962d616c506ef04f0cc9d67fa19e20 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Fri, 23 Sep 2022 02:41:42 +0200 Subject: [PATCH 28/78] Restore proxy config, even if it doesn't work with 1.8.4. --- .../rootfs/etc/nginx/templates/ingress.gtpl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index c7854e7..b44d858 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -8,22 +8,19 @@ server { allow 172.30.32.2; deny all; - proxy_pass http://octoprint/; # make sure to add trailing slash here! + proxy_set_header X-Forwarded-For 172.30.32.2; + proxy_set_header Origin 172.30.32.2; + + 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-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 {{ .ingress_entry }}; - proxy_http_version 1.1; - client_max_body_size 0; - - proxy_set_header X-Forwarded-Scheme $scheme; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_set_header X-Forwarded-For 172.30.32.2; - proxy_set_header Origin 172.30.32.2; + proxy_http_version 1.1; + client_max_body_size 0; } location /webcam/ { From 4c836767ad778cba87e0cf9c1e0c3fe0e55f63d2 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Fri, 23 Sep 2022 02:42:44 +0200 Subject: [PATCH 29/78] Update version number --- 3dprinter-octoprint/Dockerfile | 2 +- 3dprinter-octoprint/config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index d718225..038f337 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,6 +1,6 @@ ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" FROM ${BUILD_FROM} -ARG OCTOPRINT_VERSION="1.8.3" +ARG OCTOPRINT_VERSION="1.8.2" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index a44445c..ea68f7b 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.002" +version: "2022.9.003" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From 978943ef961b76966ad14b0f1dec89e389cb9f6d Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Fri, 23 Sep 2022 13:52:00 +0200 Subject: [PATCH 30/78] Set forwarded proto --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index ea68f7b..f084195 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.003" +version: "2022.9.004" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index b44d858..b257abc 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -19,6 +19,7 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Scheme $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; + proxy_set_header X-Forwarded-Proto $scheme; proxy_http_version 1.1; client_max_body_size 0; } From 4cc986888453bb8cebe0bfe420c4cf96c31e77d9 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 26 Sep 2022 21:23:47 +0200 Subject: [PATCH 31/78] Cleanup nginx config --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/templates/ingress.gtpl | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index f084195..488c7ff 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.004" +version: "2022.9.005" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index b257abc..7873a1d 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -8,20 +8,17 @@ server { allow 172.30.32.2; deny all; - proxy_set_header X-Forwarded-For 172.30.32.2; - proxy_set_header Origin 172.30.32.2; - 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 {{ .ingress_entry }}; + proxy_set_header X-Forwarded-For 172.30.32.2, $proxy_add_x_forwarded_for; # This is intentional, access through Ingress should use "autologin local". + proxy_set_header X-Forwarded-Host $host proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Script-Name {{ .ingress_entry }}; proxy_http_version 1.1; - client_max_body_size 0; + client_max_body_size 0; + # 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; } location /webcam/ { From 40d0bf6b603c506e15824b4dbbfd2636ab485146 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 26 Sep 2022 21:47:50 +0200 Subject: [PATCH 32/78] Update nginx config --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/templates/ingress.gtpl | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 488c7ff..17a797b 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.005" +version: "2022.9.006" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 7873a1d..2552013 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -9,16 +9,18 @@ server { deny all; proxy_pass http://octoprint/; # make sure to add trailing slash here! - proxy_set_header X-Forwarded-For 172.30.32.2, $proxy_add_x_forwarded_for; # This is intentional, access through Ingress should use "autologin local". - proxy_set_header X-Forwarded-Host $host + 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 172.30.32.2; # Intentional, use autologin local instead of $proxy_add_x_forwarded_for for Ingress. + proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; proxy_http_version 1.1; client_max_body_size 0; - # 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-XSRF-TOKEN $http_x_xsrf_token; } location /webcam/ { From 10d21e62ccfc438112192ec400cc32058d64206b Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 00:06:50 +0200 Subject: [PATCH 33/78] Simplify nginx ingress config --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/templates/ingress.gtpl | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 17a797b..5c49d6e 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.006" +version: "2022.9.007" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 2552013..fd5463c 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -1,29 +1,31 @@ server { listen {{ .interface }}:{{ .port }} default_server; - - include /etc/nginx/includes/server_params.conf; - include /etc/nginx/includes/proxy_params.conf; + server_name $hostname; location / { allow 172.30.32.2; deny all; - proxy_pass http://octoprint/; # make sure to add trailing slash here! + proxy_pass http://octoprint/; 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 172.30.32.2; # Intentional, use autologin local instead of $proxy_add_x_forwarded_for for Ingress. - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For 172.30.32.2; # Intentional, for autologin. + proxy_set_header X-Forwarded-Host $http_host; + proxy_set_header X-Scheme $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; proxy_http_version 1.1; - client_max_body_size 0; - - # proxy_set_header X-XSRF-TOKEN $http_x_xsrf_token; + + client_max_body_size 0; } location /webcam/ { proxy_pass {{ .camera_host }}; } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } } From 66abb15a03306a9b40b5491a76a2b8ca4f2ea006 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 00:32:21 +0200 Subject: [PATCH 34/78] Update nginx; add vim --- 3dprinter-octoprint/Dockerfile | 2 ++ 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/nginx.conf | 3 ++- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 038f337..b820093 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -24,6 +24,8 @@ RUN apt update && \ # dfu-util \ # dfu-programmer \ # stm32flash \ + # Development/testing + vim \ && \ apt clean diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 5c49d6e..6981ea3 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.007" +version: "2022.9.008" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf index e496e8b..b8edbbb 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf +++ b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf @@ -14,7 +14,8 @@ worker_processes 1; pcre_jit on; # Write error log to the add-on log. -error_log /proc/1/fd/1 error; +# error_log /proc/1/fd/1 error; +error_log /var/log/nginx/error.log debug; # Max num of simultaneous connections by a worker process. events { diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index fd5463c..d85e845 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -11,12 +11,12 @@ server { 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-Forwarded-For 172.30.32.2; # Intentional, for autologin. - proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Scheme $scheme; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; proxy_http_version 1.1; - client_max_body_size 0; } From a2ae55b2d6ca3196520ca1d8e518ce2c84880f1d Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 01:35:52 +0200 Subject: [PATCH 35/78] Minor edit to nginx ingress config --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 6981ea3..a796a2a 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.008" +version: "2022.9.009" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index d85e845..e64028f 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -11,8 +11,8 @@ server { 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-Forwarded-For 172.30.32.2; # Intentional, for autologin. + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; From 39c8fe41c3e50c62e492e76e31b54c20b27624be Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 10:59:35 +0200 Subject: [PATCH 36/78] Attempt to fix nginx through setting more headers. --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/nginx.conf | 6 ++++++ .../rootfs/etc/nginx/templates/ingress.gtpl | 8 +++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index a796a2a..696ae07 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.009" +version: "2022.9.010" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf index b8edbbb..2ed0d9c 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf +++ b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf @@ -40,6 +40,12 @@ http { '' close; } + # Should get port used, taken from https://stackoverflow.com/questions/60616564/how-to-configure-nginx-x-forwarded-port-to-be-the-originally-request-port + map $http_x_forwarded_port $port { + default $remote_port; + "~^(.*)$" $1; + } + include /etc/nginx/includes/upstream.conf; include /etc/nginx/servers/*.conf; } diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index e64028f..b3bd3b3 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -11,13 +11,15 @@ server { 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 172.30.32.2; # Intentional, for autologin. - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-For 172.30.32.2; # For autologin through Ingress. + #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Server $host; + proxy_set_header X-Forwarded-Port $port; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; proxy_http_version 1.1; - client_max_body_size 0; + client_max_body_size 0; } location /webcam/ { From ed44ae751e4e68348194186a45b31de6b9557eb5 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 13:07:04 +0200 Subject: [PATCH 37/78] Cleaned up config --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/templates/ingress.gtpl | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 696ae07..187bb4c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.010" +version: "2022.9.011" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index b3bd3b3..2b20863 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -11,15 +11,16 @@ server { 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 172.30.32.2; # For autologin through Ingress. - #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Server $host; - proxy_set_header X-Forwarded-Port $port; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; proxy_http_version 1.1; client_max_body_size 0; + + # proxy_set_header X-Forwarded-For 172.30.32.2; # For autologin through Ingress. + # proxy_set_header X-Forwarded-Server $host; + # proxy_set_header X-Forwarded-Port $port; } location /webcam/ { From be245cdda890d0c9668bcac745cf84461681156d Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 13:25:41 +0200 Subject: [PATCH 38/78] Add x-Forwarded-Host to nginx direct access. --- 3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl | 1 + 1 file changed, 1 insertion(+) diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index 7e27118..fc71291 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -6,5 +6,6 @@ server { location / { proxy_pass http://octoprint/; + proxy_set_header X-Forwarded-Host $http_host; } } From 9195f435c805026b8232fc53934e67e25149dff1 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 13:26:28 +0200 Subject: [PATCH 39/78] Autologin using Ingress --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/nginx/templates/ingress.gtpl | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 187bb4c..7f6ea82 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.011" +version: "2022.9.012" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 2b20863..4808247 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -11,16 +11,11 @@ server { 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-Forwarded-For 172.30.32.2; # Autologin since using Home Assistant Ingress. proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; proxy_http_version 1.1; client_max_body_size 0; - - # proxy_set_header X-Forwarded-For 172.30.32.2; # For autologin through Ingress. - # proxy_set_header X-Forwarded-Server $host; - # proxy_set_header X-Forwarded-Port $port; } location /webcam/ { @@ -32,3 +27,9 @@ server { root html; } } + +# The following headers/settings are currently not used. +# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +# proxy_set_header X-Forwarded-Server $host; +# proxy_set_header X-Forwarded-Port $port; +# proxy_set_header X-Forwarded-Proto $scheme; # This would set session_P80_R even if access is through HTTPS (443). \ No newline at end of file From e68661c4ca17a43f896d0aba4fe8e68e0a0ef9c3 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 13:31:42 +0200 Subject: [PATCH 40/78] Revert setting X-Forwarded-Host on nginx direct. --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 7f6ea82..95388f4 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.012" +version: "2022.9.013" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index fc71291..7e27118 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -6,6 +6,5 @@ server { location / { proxy_pass http://octoprint/; - proxy_set_header X-Forwarded-Host $http_host; } } From 095dad97f4ceda41b6ddcdb593dcdcc476ee655e Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 13:47:29 +0200 Subject: [PATCH 41/78] Add X-Scheme, use default X-Forwarded-For --- 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index 4808247..db2be98 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -11,8 +11,9 @@ server { 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 172.30.32.2; # Autologin since using Home Assistant Ingress. + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $http_host; + proxy_set_header X-Scheme $scheme; proxy_set_header X-Script-Name {{ .ingress_entry }}; proxy_http_version 1.1; client_max_body_size 0; @@ -29,7 +30,6 @@ server { } # The following headers/settings are currently not used. -# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +# proxy_set_header X-Forwarded-For 172.30.32.2; # Autologin since using Home Assistant Ingress. # proxy_set_header X-Forwarded-Server $host; # proxy_set_header X-Forwarded-Port $port; -# proxy_set_header X-Forwarded-Proto $scheme; # This would set session_P80_R even if access is through HTTPS (443). \ No newline at end of file From 09d7160573587c78e0296039df0944ce7cf5cfb8 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 13:49:49 +0200 Subject: [PATCH 42/78] Set headers for direct access. --- .../rootfs/etc/nginx/templates/direct.gtpl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index 7e27118..48825c1 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -1,10 +1,19 @@ server { listen {{ .interface }}:{{ .port }} default_server; - include /etc/nginx/includes/server_params.conf; - include /etc/nginx/includes/proxy_params.conf; + # include /etc/nginx/includes/server_params.conf; + # include /etc/nginx/includes/proxy_params.conf; location / { proxy_pass http://octoprint/; + 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_http_version 1.1; + + client_max_body_size 0; } } From 4b33079a394af530943bcf1030c98a731edc89e4 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 14:07:45 +0200 Subject: [PATCH 43/78] Update version number --- 3dprinter-octoprint/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 95388f4..3e09e48 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.013" +version: "2022.9.014" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From 33009ca2b9df76ce48753cab40aecf8e60e58424 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 27 Sep 2022 14:20:28 +0200 Subject: [PATCH 44/78] Add lines for error page in direct access --- 3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index 48825c1..2e7b303 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -16,4 +16,9 @@ server { client_max_body_size 0; } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } } From e802113c58ba9193c68ecb196f619632b9fc7daa Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 21:26:55 +0200 Subject: [PATCH 45/78] Update config --- 3dprinter-octoprint/build.yaml | 2 +- 3dprinter-octoprint/config.yaml | 4 ++-- .../rootfs/etc/nginx/templates/direct.gtpl | 12 ++++++------ .../rootfs/etc/nginx/templates/ingress.gtpl | 4 +++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 778b554..0caee25 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -9,4 +9,4 @@ labels: org.opencontainers.image.description: "3DPrinter-OctoPrint addon for Home-Assistant." org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons" args: - OCTOPRINT_VERSION: "1.8.3" + OCTOPRINT_VERSION: "1.8.4" diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 3e09e48..db9aaa4 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.014" +version: "2022.9.015" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -27,7 +27,7 @@ options: camera_url: "http://b7aa59c4-camera-mjpg-streamer/" recovery: false schema: - camera_url: "url" + camera_url: "url?" recovery: "bool" image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} tmpfs: true diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl index 2e7b303..696df34 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl @@ -7,13 +7,13 @@ server { location / { proxy_pass http://octoprint/; 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 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_http_version 1.1; - + client_max_body_size 0; } diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl index db2be98..a2a5eb4 100644 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl @@ -7,10 +7,12 @@ server { deny all; proxy_pass http://octoprint/; - proxy_set_header Host $http_host; + proxy_pass_request_headers on; + proxy_set_header Host $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 172.30.32.2; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Scheme $scheme; From 16870e60e8f7a1a71f88a641203918d1404b18b4 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 21:58:17 +0200 Subject: [PATCH 46/78] Replace nginx with Caddy --- 3dprinter-octoprint/Dockerfile | 13 +++++++++- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/caddy/Caddyfile | 1 + .../rootfs/etc/caddy/sites-enabled/.gitkeep | 0 .../etc/cont-init.d/{nginx.sh => proxy.sh} | 10 ++++---- .../etc/services.d/{nginx => proxy}/finish | 6 ++--- .../etc/services.d/{nginx => proxy}/run | 7 +++--- .../rootfs/root/config/octoprint/config.yaml | 1 + .../usr/share/tempio/Caddyfile.direct.gtpl | 15 ++++++++++++ .../usr/share/tempio/Caddyfile.ingress.gtpl | 24 +++++++++++++++++++ 10 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 3dprinter-octoprint/rootfs/etc/caddy/Caddyfile create mode 100644 3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitkeep rename 3dprinter-octoprint/rootfs/etc/cont-init.d/{nginx.sh => proxy.sh} (75%) rename 3dprinter-octoprint/rootfs/etc/services.d/{nginx => proxy}/finish (59%) rename 3dprinter-octoprint/rootfs/etc/services.d/{nginx => proxy}/run (71%) create mode 100644 3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl create mode 100644 3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index b820093..d26ea1c 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -9,6 +9,16 @@ ENV PYTHONPATH=/data/python/octoprint ENV PYTHONUSERBASE=/data/python/octoprint ENV PATH=/data/python/octoprint/bin:${PATH} +# Preparation for install of Caddy +RUN apt install -y \ + --no-install-recommends \ + debian-keyring \ + debian-archive-keyring \ + apt-transport-https \ + gpg \ + && curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \ + && curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list + # Install dependencies RUN apt update && \ apt install -y \ @@ -17,7 +27,8 @@ RUN apt update && \ python3-dev \ python3-wheel \ build-essential \ - nginx \ + caddy \ + # nginx \ # Extras. # ffmpeg \ # avrdude \ diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index db9aaa4..d12b51e 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.015" +version: "2022.9.016" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile new file mode 100644 index 0000000..061e629 --- /dev/null +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -0,0 +1 @@ +import sites-enabled/* \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitkeep b/3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh similarity index 75% rename from 3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh rename to 3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh index f9c3440..07a4464 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/nginx.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -1,7 +1,7 @@ #!/usr/bin/with-contenv bashio # ============================================================================== # Add-on: 3dprinter-octoprint -# Configures NGINX +# Configures proxy # ============================================================================== # Generate Ingress configuration @@ -11,8 +11,8 @@ bashio::var.json \ ingress_entry "$(bashio::addon.ingress_entry)" \ camera_host "$(bashio::config 'camera_url')" \ | tempio \ - -template /etc/nginx/templates/ingress.gtpl \ - -out /etc/nginx/servers/ingress.conf + -template /usr/share/tempio/Caddyfile.ingress.gtpl \ + -out /etc/caddy/sites-enabled/ingress # Generate direct access configuration, if enabled. if bashio::var.has_value "$(bashio::addon.port 5000)"; then @@ -20,6 +20,6 @@ if bashio::var.has_value "$(bashio::addon.port 5000)"; then interface "$(bashio::addon.ip_address)" \ port "^$(bashio::addon.port 5000)" \ | tempio \ - -template /etc/nginx/templates/direct.gtpl \ - -out /etc/nginx/servers/direct.conf + -template /usr/share/tempio/Caddyfile.direct.gtpl \ + -out /etc/caddy/sites-enabled/direct fi diff --git a/3dprinter-octoprint/rootfs/etc/services.d/nginx/finish b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish similarity index 59% rename from 3dprinter-octoprint/rootfs/etc/services.d/nginx/finish rename to 3dprinter-octoprint/rootfs/etc/services.d/proxy/finish index d015336..f19830d 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/nginx/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish @@ -1,9 +1,7 @@ #!/usr/bin/execlineb -S0 # ============================================================================== # Add-on: 3dprinter-octoprint -# Take down the S6 supervision tree when Nginx fails +# Stop reverse proxy # ============================================================================== -if -n { s6-test $# -ne 0 } -if -n { s6-test ${1} -eq 256 } -s6-svscanctl -t /var/run/s6/services +caddy stop diff --git a/3dprinter-octoprint/rootfs/etc/services.d/nginx/run b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run similarity index 71% rename from 3dprinter-octoprint/rootfs/etc/services.d/nginx/run rename to 3dprinter-octoprint/rootfs/etc/services.d/proxy/run index 267e1bb..f7111b6 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/nginx/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run @@ -1,11 +1,12 @@ #!/usr/bin/with-contenv bashio # ============================================================================== # Add-on: 3dprinter-octoprint -# Runs the Nginx daemon +# Runs the reverse proxy. # ============================================================================== # Wait for web server to be available bashio::net.wait_for 5000 -bashio::log.info "Starting NGinx..." -exec nginx +bashio::log.info "Starting proxy..." + +caddy start --config /etc/caddy/Caddyfile --watch diff --git a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml index a5b1d15..de0d5ff 100644 --- a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml +++ b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml @@ -11,6 +11,7 @@ folder: generated: /tmp/octoprint/generated timelapse_tmp: /tmp/octoprint/timelapse/tmp server: + allowFraming: true commands: serverRestartCommand: /scripts/octoprint_restart.sh systemRestartCommand: /scripts/system_restart.sh diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl new file mode 100644 index 0000000..06f1f41 --- /dev/null +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl @@ -0,0 +1,15 @@ +# OctoPrint WebUI +:5000 { + reverse_proxy http://127.0.0.1:80 { + header_up X-Scheme {scheme} + } +} + +# Camera +:8000 { + reverse_proxy http://127.0.0.1:8080 { + header_up X-Scheme {scheme} + } +} + +# Moonraker - expose as-is. \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl new file mode 100644 index 0000000..0d586b6 --- /dev/null +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -0,0 +1,24 @@ +:8099 { + @ingress { + remote_ip 172.30.32.2 + } + {{ if .mjpg_streamer }} + handle_path /webcam* { + reverse_proxy 127.0.0.1:8080 { + flush_interval -1 + } + } + {{ end }} + handle { + {{ if .recovery }} + rewrite / /recovery + {{ end }} + reverse_proxy @ingress localhost:80 { + header_up X-Script-Name {{ env "ingress_entry" }} + header_up -Origin + header_up Origin 172.30.32.2 + header_up X-Forwarded-For 172.30.32.2 + flush_interval -1 + } + } +} \ No newline at end of file From cb41b36681f42646ee0f3963ebe7e6e3104ce70c Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 22:01:02 +0200 Subject: [PATCH 47/78] Add changelog --- 3dprinter-octoprint/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 3dprinter-octoprint/CHANGELOG.md diff --git a/3dprinter-octoprint/CHANGELOG.md b/3dprinter-octoprint/CHANGELOG.md new file mode 100644 index 0000000..a9d0efa --- /dev/null +++ b/3dprinter-octoprint/CHANGELOG.md @@ -0,0 +1 @@ +- Change reverse proxy from nginx to Caddy \ No newline at end of file From 0951fc79b397ac3d63beae8e13e3d7e9c5543e3c Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 22:03:52 +0200 Subject: [PATCH 48/78] apt update before first install --- 3dprinter-octoprint/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index d26ea1c..7784f81 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -10,7 +10,8 @@ ENV PYTHONUSERBASE=/data/python/octoprint ENV PATH=/data/python/octoprint/bin:${PATH} # Preparation for install of Caddy -RUN apt install -y \ +RUN apt update \ + && apt install -y \ --no-install-recommends \ debian-keyring \ debian-archive-keyring \ @@ -20,15 +21,14 @@ RUN apt install -y \ && curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list # Install dependencies -RUN apt update && \ - apt install -y \ +RUN apt update \ + && apt install -y \ --no-install-recommends \ python3-venv \ python3-dev \ python3-wheel \ build-essential \ caddy \ - # nginx \ # Extras. # ffmpeg \ # avrdude \ From 70f706881865f44ced88ffd0e3cd92e7f6e0f397 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 22:10:05 +0200 Subject: [PATCH 49/78] Remove i386 from 3dprinter-octoprint arch. --- .github/workflows/3dprinter-octoprint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/3dprinter-octoprint.yml b/.github/workflows/3dprinter-octoprint.yml index c99e69c..6193dc8 100644 --- a/.github/workflows/3dprinter-octoprint.yml +++ b/.github/workflows/3dprinter-octoprint.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: addon: ["3dprinter-octoprint"] - arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] + arch: ["aarch64", "amd64", "armhf", "armv7"] steps: - name: Check out the repository uses: actions/checkout@v3 From 2be4dcf3926d50ba356045f9e6d4393b6100ce2a Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 22:36:38 +0200 Subject: [PATCH 50/78] Cleanup Caddy config --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/caddy/sites-enabled/.gitkeep | 0 .../usr/share/tempio/Caddyfile.ingress.gtpl | 28 ++++++------------- 3 files changed, 10 insertions(+), 20 deletions(-) delete mode 100644 3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitkeep diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index d12b51e..f06360c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.016" +version: "2022.9.017" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitkeep b/3dprinter-octoprint/rootfs/etc/caddy/sites-enabled/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl index 0d586b6..4e04120 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -1,24 +1,14 @@ -:8099 { +:{{ .port }} { @ingress { - remote_ip 172.30.32.2 + remote_ip {{ .interface }} } - {{ if .mjpg_streamer }} - handle_path /webcam* { - reverse_proxy 127.0.0.1:8080 { - flush_interval -1 - } - } - {{ end }} handle { - {{ if .recovery }} - rewrite / /recovery - {{ end }} - reverse_proxy @ingress localhost:80 { - header_up X-Script-Name {{ env "ingress_entry" }} - header_up -Origin - header_up Origin 172.30.32.2 - header_up X-Forwarded-For 172.30.32.2 - flush_interval -1 + reverse_proxy @ingress 127.0.0.1:80 { + header_up X-Script-Name {{ .ingress_entry }} + # header_up -Origin + # header_up Origin 172.30.32.2 + # header_up X-Forwarded-For 172.30.32.2 + # flush_interval -1 } } -} \ No newline at end of file +} From d2801c1e142e2f40f07a43bd0b979c7270e98174 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 22:40:05 +0200 Subject: [PATCH 51/78] Make sure sites-enabled folder exists --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index f06360c..85a781d 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.017" +version: "2022.9.018" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." 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 07a4464..8c14eb3 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -4,6 +4,8 @@ # Configures proxy # ============================================================================== +mkdir -p /etc/caddy/sites-enabled + # Generate Ingress configuration bashio::var.json \ interface "$(bashio::addon.ip_address)" \ From e5cf716506a786a3e2ddddf71bc5787620e744ab Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 22:56:13 +0200 Subject: [PATCH 52/78] Use suffix for Caddy config files --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/caddy/Caddyfile | 2 +- 3dprinter-octoprint/rootfs/etc/caddy/configs/.gitkeep | 0 3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh | 4 ++-- .../rootfs/usr/share/tempio/Caddyfile.ingress.gtpl | 8 ++------ 5 files changed, 6 insertions(+), 10 deletions(-) create mode 100644 3dprinter-octoprint/rootfs/etc/caddy/configs/.gitkeep diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 85a781d..c3ee73c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.018" +version: "2022.9.019" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index 061e629..005a797 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -1 +1 @@ -import sites-enabled/* \ No newline at end of file +import configs/*.caddy \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/etc/caddy/configs/.gitkeep b/3dprinter-octoprint/rootfs/etc/caddy/configs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh index 8c14eb3..8809116 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -14,7 +14,7 @@ bashio::var.json \ camera_host "$(bashio::config 'camera_url')" \ | tempio \ -template /usr/share/tempio/Caddyfile.ingress.gtpl \ - -out /etc/caddy/sites-enabled/ingress + -out /etc/caddy/configs/ingress.caddy # Generate direct access configuration, if enabled. if bashio::var.has_value "$(bashio::addon.port 5000)"; then @@ -23,5 +23,5 @@ if bashio::var.has_value "$(bashio::addon.port 5000)"; then port "^$(bashio::addon.port 5000)" \ | tempio \ -template /usr/share/tempio/Caddyfile.direct.gtpl \ - -out /etc/caddy/sites-enabled/direct + -out /etc/caddy/configs/direct.caddy fi diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl index 4e04120..f70cf54 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -1,14 +1,10 @@ -:{{ .port }} { +:0899 { @ingress { - remote_ip {{ .interface }} + remote_ip 172.30.32.2 } handle { reverse_proxy @ingress 127.0.0.1:80 { header_up X-Script-Name {{ .ingress_entry }} - # header_up -Origin - # header_up Origin 172.30.32.2 - # header_up X-Forwarded-For 172.30.32.2 - # flush_interval -1 } } } From 7bb916b4a5eb148e716f9617b43dad95365c8bf4 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 23:08:58 +0200 Subject: [PATCH 53/78] Set XDG_CONFIG_HOME --- 3dprinter-octoprint/build.yaml | 1 + 3dprinter-octoprint/config.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 0caee25..01794c6 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -10,3 +10,4 @@ labels: org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons" args: OCTOPRINT_VERSION: "1.8.4" + XDG_CONFIG_HOME: /data/config/ diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index c3ee73c..9f2821f 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.019" +version: "2022.9.020" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From 8eaaf3283b5fa21fb53dd908d5574c2c853b5876 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 23:18:51 +0200 Subject: [PATCH 54/78] Update xdg_config/data_home --- 3dprinter-octoprint/Dockerfile | 2 ++ 3dprinter-octoprint/build.yaml | 3 ++- 3dprinter-octoprint/config.yaml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 7784f81..e0d7900 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -3,6 +3,8 @@ FROM ${BUILD_FROM} ARG OCTOPRINT_VERSION="1.8.2" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} +ENV XDG_CONFIG_HOME=${XDG_CONFIG_HOME} +ENV XDG_DATA_HOME=${XDG_DATA_HOME} # Setup path for persistent install of Python packages ENV PYTHONPATH=/data/python/octoprint diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 01794c6..723fe20 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -10,4 +10,5 @@ labels: org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons" args: OCTOPRINT_VERSION: "1.8.4" - XDG_CONFIG_HOME: /data/config/ + XDG_CONFIG_HOME: /data/config + XDG_DATA_HOME: /data/config diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 9f2821f..697d5ed 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.020" +version: "2022.9.021" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From 1a5b481dc8dd58227870331a1292d5efb37b9599 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 23:26:12 +0200 Subject: [PATCH 55/78] Fix XDG paths --- 3dprinter-octoprint/CHANGELOG.md | 1 + 3dprinter-octoprint/Dockerfile | 2 ++ 3dprinter-octoprint/build.yaml | 4 ++-- 3dprinter-octoprint/config.yaml | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/3dprinter-octoprint/CHANGELOG.md b/3dprinter-octoprint/CHANGELOG.md index a9d0efa..95fb1e4 100644 --- a/3dprinter-octoprint/CHANGELOG.md +++ b/3dprinter-octoprint/CHANGELOG.md @@ -1 +1,2 @@ +- Fixes to Caddy XDG paths - Change reverse proxy from nginx to Caddy \ No newline at end of file diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index e0d7900..a21df7b 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,6 +1,8 @@ ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" FROM ${BUILD_FROM} ARG OCTOPRINT_VERSION="1.8.2" +ARG XDG_CONFIG_HOME="/data/config" +ARG XDG_DATA_HOME="/data/config" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} ENV XDG_CONFIG_HOME=${XDG_CONFIG_HOME} diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 723fe20..f5587a7 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -10,5 +10,5 @@ labels: org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons" args: OCTOPRINT_VERSION: "1.8.4" - XDG_CONFIG_HOME: /data/config - XDG_DATA_HOME: /data/config + XDG_CONFIG_HOME: "/data/config" + XDG_DATA_HOME: "/data/config" diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 697d5ed..a3b005d 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.021" +version: "2022.9.022" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" From a8f4d2ebfea67a492c7c2809d488a61b28a10958 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Sun, 2 Oct 2022 23:52:22 +0200 Subject: [PATCH 56/78] Modify services finish script --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh | 2 +- 3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish | 7 ++++--- 3dprinter-octoprint/rootfs/etc/services.d/proxy/finish | 2 -- 3dprinter-octoprint/rootfs/etc/services.d/proxy/run | 2 +- .../rootfs/usr/share/tempio/Caddyfile.ingress.gtpl | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index a3b005d..9d8fbdf 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.022" +version: "2022.9.023" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." 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 8809116..dc5527b 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -4,7 +4,7 @@ # Configures proxy # ============================================================================== -mkdir -p /etc/caddy/sites-enabled +mkdir -p /etc/caddy/configs # Generate Ingress configuration bashio::var.json \ diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish index 4cea07a..4595fc3 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/finish @@ -3,7 +3,8 @@ # Add-on: 3dprinter-octoprint # Take down the S6 supervision tree when OctoPrint fails # ============================================================================== -if -n { s6-test $# -ne 0 } -if -n { s6-test ${1} -eq 256 } -s6-svscanctl -t /var/run/s6/services +# if -n { s6-test $# -ne 0 } +# if -n { s6-test ${1} -eq 256 } +# +# s6-svscanctl -t /var/run/s6/services diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish index f19830d..14df06e 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish @@ -3,5 +3,3 @@ # Add-on: 3dprinter-octoprint # Stop reverse proxy # ============================================================================== - -caddy stop diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run index f7111b6..c0be73b 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run @@ -9,4 +9,4 @@ bashio::net.wait_for 5000 bashio::log.info "Starting proxy..." -caddy start --config /etc/caddy/Caddyfile --watch +exec caddy run --config /etc/caddy/Caddyfile diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl index f70cf54..2aed2f7 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -1,9 +1,9 @@ -:0899 { +:8099 { @ingress { remote_ip 172.30.32.2 } handle { - reverse_proxy @ingress 127.0.0.1:80 { + reverse_proxy @ingress 127.0.0.1:5000 { header_up X-Script-Name {{ .ingress_entry }} } } From afb711b57d334a05db6c82c51ca29b590416f481 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 3 Oct 2022 00:17:27 +0200 Subject: [PATCH 57/78] Use caddy start instead of exec caddy run --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/services.d/proxy/finish | 2 ++ 3dprinter-octoprint/rootfs/etc/services.d/proxy/run | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 9d8fbdf..377071a 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.023" +version: "2022.9.024" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish index 14df06e..f19830d 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish @@ -3,3 +3,5 @@ # Add-on: 3dprinter-octoprint # Stop reverse proxy # ============================================================================== + +caddy stop diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run index c0be73b..68b79c1 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run @@ -9,4 +9,5 @@ bashio::net.wait_for 5000 bashio::log.info "Starting proxy..." -exec caddy run --config /etc/caddy/Caddyfile +# exec caddy run --config /etc/caddy/Caddyfile +caddy start --config /etc/caddy/Caddyfile \ No newline at end of file From eee3f02dda5d03fe9f2cc3f920f45020c19832e4 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 3 Oct 2022 00:34:08 +0200 Subject: [PATCH 58/78] Make sure XDG_ variables exists at Caddy launch --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/services.d/proxy/run | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 377071a..538312b 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.024" +version: "2022.9.025" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run index 68b79c1..3394490 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run @@ -10,4 +10,4 @@ bashio::net.wait_for 5000 bashio::log.info "Starting proxy..." # exec caddy run --config /etc/caddy/Caddyfile -caddy start --config /etc/caddy/Caddyfile \ No newline at end of file +XDG_CONFIG_HOME=/data/config XDG_DATA_HOME=/data/config caddy start --config /etc/caddy/Caddyfile \ No newline at end of file From a48be0ed52b5a0a226044e5b8ba2a4e2fba7a1dc Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 3 Oct 2022 01:08:59 +0200 Subject: [PATCH 59/78] Update for Caddy --- 3dprinter-octoprint/Dockerfile | 4 ---- 3dprinter-octoprint/build.yaml | 2 -- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/caddy/env | 2 ++ 3dprinter-octoprint/rootfs/etc/services.d/proxy/finish | 2 -- 3dprinter-octoprint/rootfs/etc/services.d/proxy/run | 2 +- 3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml | 1 - 7 files changed, 4 insertions(+), 11 deletions(-) create mode 100644 3dprinter-octoprint/rootfs/etc/caddy/env diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index a21df7b..7784f81 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,12 +1,8 @@ ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" FROM ${BUILD_FROM} ARG OCTOPRINT_VERSION="1.8.2" -ARG XDG_CONFIG_HOME="/data/config" -ARG XDG_DATA_HOME="/data/config" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} -ENV XDG_CONFIG_HOME=${XDG_CONFIG_HOME} -ENV XDG_DATA_HOME=${XDG_DATA_HOME} # Setup path for persistent install of Python packages ENV PYTHONPATH=/data/python/octoprint diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index f5587a7..0caee25 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -10,5 +10,3 @@ labels: org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons" args: OCTOPRINT_VERSION: "1.8.4" - XDG_CONFIG_HOME: "/data/config" - XDG_DATA_HOME: "/data/config" diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 538312b..7aea042 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.025" +version: "2022.9.026" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/caddy/env b/3dprinter-octoprint/rootfs/etc/caddy/env new file mode 100644 index 0000000..810aa29 --- /dev/null +++ b/3dprinter-octoprint/rootfs/etc/caddy/env @@ -0,0 +1,2 @@ +XDG_CONFIG_HOME="/data/caddy" +XDG_DATA_HOME="/data/caddy" \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish index f19830d..14df06e 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/finish @@ -3,5 +3,3 @@ # Add-on: 3dprinter-octoprint # Stop reverse proxy # ============================================================================== - -caddy stop diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run index 3394490..c0e1baf 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run @@ -10,4 +10,4 @@ bashio::net.wait_for 5000 bashio::log.info "Starting proxy..." # exec caddy run --config /etc/caddy/Caddyfile -XDG_CONFIG_HOME=/data/config XDG_DATA_HOME=/data/config caddy start --config /etc/caddy/Caddyfile \ No newline at end of file +exec caddy run --config /etc/caddy/Caddyfile --envfile /etc/caddy/env diff --git a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml index de0d5ff..a5b1d15 100644 --- a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml +++ b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml @@ -11,7 +11,6 @@ folder: generated: /tmp/octoprint/generated timelapse_tmp: /tmp/octoprint/timelapse/tmp server: - allowFraming: true commands: serverRestartCommand: /scripts/octoprint_restart.sh systemRestartCommand: /scripts/system_restart.sh From f0e4efc5244cde9fe58efb6f940dc127bbfef20c Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 3 Oct 2022 03:00:51 +0200 Subject: [PATCH 60/78] Simplify X-Script-Name; improve proxy --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/caddy/env | 4 ++-- 3dprinter-octoprint/rootfs/scripts/proxy_restart.sh | 5 +++++ .../rootfs/usr/share/tempio/Caddyfile.ingress.gtpl | 6 +++++- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 3dprinter-octoprint/rootfs/scripts/proxy_restart.sh diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 7aea042..db6774f 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.026" +version: "2022.9.027" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/caddy/env b/3dprinter-octoprint/rootfs/etc/caddy/env index 810aa29..33ec339 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/env +++ b/3dprinter-octoprint/rootfs/etc/caddy/env @@ -1,2 +1,2 @@ -XDG_CONFIG_HOME="/data/caddy" -XDG_DATA_HOME="/data/caddy" \ No newline at end of file +XDG_CONFIG_HOME="/data/config" +XDG_DATA_HOME="/data/config" \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/scripts/proxy_restart.sh b/3dprinter-octoprint/rootfs/scripts/proxy_restart.sh new file mode 100644 index 0000000..4ec7fd8 --- /dev/null +++ b/3dprinter-octoprint/rootfs/scripts/proxy_restart.sh @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +bashio::log.warning "Restart proxy." + +s6-svc -r /var/run/s6/legacy-services/proxy diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl index 2aed2f7..0ea0587 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -1,10 +1,14 @@ +# { +# debug +# } :8099 { @ingress { remote_ip 172.30.32.2 } handle { reverse_proxy @ingress 127.0.0.1:5000 { - header_up X-Script-Name {{ .ingress_entry }} + # header_up X-Script-Name {{ .ingress_entry }} + header_up X-Script-Name {http.request.header.X-Ingress-Path} } } } From f6484bdc2da0a86bd2dda016b46cc4dc9a140e73 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 4 Oct 2022 23:28:15 +0200 Subject: [PATCH 61/78] Modify to suggestion of Caddy file --- 3dprinter-octoprint/DOCS.md | 3 +++ 3dprinter-octoprint/config.yaml | 5 +++-- 3dprinter-octoprint/rootfs/etc/caddy/Caddyfile | 2 +- 3dprinter-octoprint/rootfs/etc/caddy/env | 2 +- .../rootfs/root/config/octoprint/config.yaml | 1 + .../rootfs/usr/share/tempio/Caddyfile.ingress.gtpl | 13 +++++++------ 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/3dprinter-octoprint/DOCS.md b/3dprinter-octoprint/DOCS.md index e69de29..ef72f39 100644 --- a/3dprinter-octoprint/DOCS.md +++ b/3dprinter-octoprint/DOCS.md @@ -0,0 +1,3 @@ +# Dev +> image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} + diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index db6774f..10663e1 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.027" +version: "2022.9.029" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -26,8 +26,9 @@ ports_description: options: camera_url: "http://b7aa59c4-camera-mjpg-streamer/" recovery: false + ssl_fix: false schema: camera_url: "url?" recovery: "bool" -image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} + ssl_fix: "bool?" tmpfs: true diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index 005a797..374d551 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -1 +1 @@ -import configs/*.caddy \ No newline at end of file +import configs/*.caddy diff --git a/3dprinter-octoprint/rootfs/etc/caddy/env b/3dprinter-octoprint/rootfs/etc/caddy/env index 33ec339..49daa0e 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/env +++ b/3dprinter-octoprint/rootfs/etc/caddy/env @@ -1,2 +1,2 @@ XDG_CONFIG_HOME="/data/config" -XDG_DATA_HOME="/data/config" \ No newline at end of file +XDG_DATA_HOME="/data/config" diff --git a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml index a5b1d15..de0d5ff 100644 --- a/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml +++ b/3dprinter-octoprint/rootfs/root/config/octoprint/config.yaml @@ -11,6 +11,7 @@ folder: generated: /tmp/octoprint/generated timelapse_tmp: /tmp/octoprint/timelapse/tmp server: + allowFraming: true commands: serverRestartCommand: /scripts/octoprint_restart.sh systemRestartCommand: /scripts/system_restart.sh diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl index 0ea0587..ab095bb 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -1,14 +1,15 @@ -# { -# debug -# } :8099 { @ingress { remote_ip 172.30.32.2 } - handle { + handle_path {http.request.header.X-Ingress-Path}/* { reverse_proxy @ingress 127.0.0.1:5000 { - # header_up X-Script-Name {{ .ingress_entry }} - header_up X-Script-Name {http.request.header.X-Ingress-Path} + header_up X-Script-Name {http.request.header.X-Ingress-Path}/ + header_up -Origin + header_up Origin 172.30.32.2 + header_up X-Forwarded-For 172.30.32.2 + header_up X-Scheme {scheme} + flush_interval -1 } } } From ee5f440a7f519040a5ce586e4197a712538cbce9 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Wed, 5 Oct 2022 00:03:59 +0200 Subject: [PATCH 62/78] Modify Caddyfile for Ingress --- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/usr/share/tempio/Caddyfile.ingress.gtpl | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 10663e1..c4abace 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.029" +version: "2022.9.030" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl index ab095bb..0410c74 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -2,9 +2,10 @@ @ingress { remote_ip 172.30.32.2 } - handle_path {http.request.header.X-Ingress-Path}/* { + handle { + uri strip_prefix {{ .ingress_entry }} reverse_proxy @ingress 127.0.0.1:5000 { - header_up X-Script-Name {http.request.header.X-Ingress-Path}/ + header_up X-Script-Name {{ .ingress_entry }} header_up -Origin header_up Origin 172.30.32.2 header_up X-Forwarded-For 172.30.32.2 From 8236053ec9268ed4cffbd2f38d9ce4fce49c202f Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Wed, 5 Oct 2022 02:01:44 +0200 Subject: [PATCH 63/78] Add global log config to Caddyfile --- 3dprinter-octoprint/rootfs/etc/caddy/Caddyfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index 374d551..904dce3 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -1 +1,6 @@ +{ + log { + format console + } +} import configs/*.caddy From da180c44f4bb42ff7cfce9c435d9aecae86213a3 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Wed, 5 Oct 2022 10:43:31 +0200 Subject: [PATCH 64/78] Cleanup Caddy; update icon --- 3dprinter-octoprint/CHANGELOG.md | 2 ++ 3dprinter-octoprint/config.yaml | 6 +++--- 3dprinter-octoprint/icon.png | Bin 49206 -> 49206 bytes .../usr/share/tempio/Caddyfile.ingress.gtpl | 8 ++------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/3dprinter-octoprint/CHANGELOG.md b/3dprinter-octoprint/CHANGELOG.md index 95fb1e4..b8841e8 100644 --- a/3dprinter-octoprint/CHANGELOG.md +++ b/3dprinter-octoprint/CHANGELOG.md @@ -1,2 +1,4 @@ +- Update icon to colored nozzle. +- Cleanup Caddy config. - Fixes to Caddy XDG paths - Change reverse proxy from nginx to Caddy \ No newline at end of file diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index c4abace..0237e28 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.030" +version: "2022.9.031" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -26,9 +26,9 @@ ports_description: options: camera_url: "http://b7aa59c4-camera-mjpg-streamer/" recovery: false - ssl_fix: false + sslFix: false schema: camera_url: "url?" recovery: "bool" - ssl_fix: "bool?" + sslFix: "bool?" tmpfs: true diff --git a/3dprinter-octoprint/icon.png b/3dprinter-octoprint/icon.png index 9222efd99e2dde507055e24f60d2c44c679c5a3b..537eaa5d5ab559d383c3a0afa6fd9d7c47217681 100644 GIT binary patch delta 123 zcmdniz`U)2dBd4-HWit-Ks3>D{^VV;{F57$jtN0TkjaUTGl`NtEP<>GnLW{Q8pwoA Hv1Z8tLtZkE delta 74 zcmdniz`U)2dBd6Ti3Uq2?~3K0+@N#}NDEC`kv1{F7^lc#po|1qjR8o_rdYFN00J^0 Ac>n+a diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl index 0410c74..b593543 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -2,15 +2,11 @@ @ingress { remote_ip 172.30.32.2 } + uri strip_prefix {{ .ingress_entry }} handle { - uri strip_prefix {{ .ingress_entry }} reverse_proxy @ingress 127.0.0.1:5000 { - header_up X-Script-Name {{ .ingress_entry }} - header_up -Origin - header_up Origin 172.30.32.2 - header_up X-Forwarded-For 172.30.32.2 + header_up X-Script-Name {{ .ingress_entry }}/ header_up X-Scheme {scheme} - flush_interval -1 } } } From 288a55963cfa5d19549b073a2f332c0d7d035e45 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Thu, 6 Oct 2022 01:39:52 +0200 Subject: [PATCH 65/78] Cleanup for testing --- 3dprinter-octoprint/Dockerfile | 2 +- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/caddy/Caddyfile | 1 + .../rootfs/etc/cont-init.d/octoprint.sh | 25 +++++++++++-------- .../rootfs/etc/services.d/octoprint/run | 2 ++ .../rootfs/etc/services.d/proxy/run | 1 - .../usr/share/tempio/Caddyfile.direct.gtpl | 9 ------- 7 files changed, 19 insertions(+), 23 deletions(-) diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 7784f81..2c04504 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,6 +1,6 @@ ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" FROM ${BUILD_FROM} -ARG OCTOPRINT_VERSION="1.8.2" +ARG OCTOPRINT_VERSION="1.8.0" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 0237e28..e65eae3 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.031" +version: "2022.9.032" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index 904dce3..cba030d 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -1,4 +1,5 @@ { + debug log { format console } diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index b3f31cd..6087224 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -4,10 +4,10 @@ # s6-overlay docs: https://github.com/just-containers/s6-overlay # ============================================================================== -{ # Check if OctoPrint is installed +{ # Check if OctoPrint is installed. octoprint --version -} || { # Otherwise install - { # Check if Python is available at `/data/python/octoprint` according to PATH) +} || { # Otherwise install it. + { # Check if Python is available (at `/data/python/octoprint` according to PATH) python --version } || { # Otherwise create Python virtual environment. python3 -m venv /data/python/octoprint @@ -15,23 +15,26 @@ pip install wheel } pip install octoprint==$OCTOPRINT_VERSION + # Temporary bugfix, to be removed after 1.8.5 is released. + sed -i 's+//,+//g,+g' /data/python/octoprint/lib/python3.9/site-packages/octoprint/static/js/app/client/base.js } # Copy OctoPrint config to persistent storage, if missing. if [ ! -f /data/config/octoprint/config.yaml ]; then if [ -f /root/config/octoprint/config.yaml ]; then mkdir -p /data/config/octoprint - cp /root/config/octoprint/config.yaml /data/config/octoprint/config.yaml + # cp /root/config/octoprint/config.yaml /data/config/octoprint/config.yaml bashio::log.notice "Default OctoPrint config copied" else bashio::log.warning "Default OctoPrint config not found" fi fi -{ # Make sure Ingress user for OctoPrint exists. - bashio::log.notice "Ensure Ingress user (homeassistant) exist." - new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo) - octoprint --basedir /data/config/octoprint user add homeassistant --password "$new_password" --group users --group admins # 2> /dev/null -} || { # catch - bashio::log.warning "Failed to ensure Ingress user exists, may not be able to launch." -} +# TODO: Check if user exists before setting password. +# { # Make sure Ingress user for OctoPrint exists. +# bashio::log.notice "Ensure Ingress user (homeassistant) exist." +# new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo) +# octoprint --basedir /data/config/octoprint user add homeassistant --password "$new_password" --group users --group admins # 2> /dev/null +# } || { # catch +# bashio::log.warning "Failed to ensure Ingress user exists, may not be able to launch." +# } diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run index 5f63fc5..224c4c1 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run @@ -4,5 +4,7 @@ # Runs OctoPrint # ============================================================================== +bashio::log.info "Starting OctoPrint..." + ## Run your program exec octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 5000 --basedir /data/config/octoprint diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run index c0e1baf..6be8d30 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run @@ -9,5 +9,4 @@ bashio::net.wait_for 5000 bashio::log.info "Starting proxy..." -# exec caddy run --config /etc/caddy/Caddyfile exec caddy run --config /etc/caddy/Caddyfile --envfile /etc/caddy/env diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl index 06f1f41..1f6971e 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl @@ -4,12 +4,3 @@ header_up X-Scheme {scheme} } } - -# Camera -:8000 { - reverse_proxy http://127.0.0.1:8080 { - header_up X-Scheme {scheme} - } -} - -# Moonraker - expose as-is. \ No newline at end of file From dcc0a2140436f6ed9516ef35643cb504ccc13aa6 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Thu, 6 Oct 2022 11:16:12 +0200 Subject: [PATCH 66/78] Add headers to Caddy file; use pre-built image --- 3dprinter-octoprint/config.yaml | 5 ++--- .../rootfs/usr/share/tempio/Caddyfile.ingress.gtpl | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index e65eae3..dc9b1ff 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.032" +version: "2022.9.033" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -26,9 +26,8 @@ ports_description: options: camera_url: "http://b7aa59c4-camera-mjpg-streamer/" recovery: false - sslFix: false schema: camera_url: "url?" recovery: "bool" - sslFix: "bool?" tmpfs: true +image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl index b593543..22ff3eb 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl @@ -5,8 +5,12 @@ uri strip_prefix {{ .ingress_entry }} handle { reverse_proxy @ingress 127.0.0.1:5000 { - header_up X-Script-Name {{ .ingress_entry }}/ + header_up X-Script-Name {{ .ingress_entry }} + header_up -Origin + header_up Origin 172.30.32.2 + header_up X-Forwarded-For 172.30.32.2 header_up X-Scheme {scheme} + flush_interval -1 } } } From 9f80b8afa531014cbd8f480f8fafaaad650268de Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 11 Oct 2022 15:30:58 +0200 Subject: [PATCH 67/78] Use single file for Caddy --- 3dprinter-octoprint/config.yaml | 3 +-- .../rootfs/etc/caddy/Caddyfile | 1 + .../rootfs/etc/cont-init.d/octoprint.sh | 6 ++---- .../rootfs/etc/cont-init.d/proxy.sh | 19 ++++-------------- .../usr/share/tempio/Caddyfile.direct.gtpl | 6 ------ ...{Caddyfile.ingress.gtpl => Caddyfile.gtpl} | 20 +++++++++++++++++++ 6 files changed, 28 insertions(+), 27 deletions(-) delete mode 100644 3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl rename 3dprinter-octoprint/rootfs/usr/share/tempio/{Caddyfile.ingress.gtpl => Caddyfile.gtpl} (54%) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index dc9b1ff..da53eca 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.9.033" +version: "2022.10.0" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -30,4 +30,3 @@ schema: camera_url: "url?" recovery: "bool" tmpfs: true -image: ghcr.io/fredrikbaberg/addon-3dprinter-octoprint-{arch} \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index cba030d..39ff23e 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -2,6 +2,7 @@ debug log { format console + output file /var/log/caddy.log } } import configs/*.caddy diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index 6087224..961ea4c 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -5,7 +5,7 @@ # ============================================================================== { # Check if OctoPrint is installed. - octoprint --version + octoprint -b /data/config/octoprint --version } || { # Otherwise install it. { # Check if Python is available (at `/data/python/octoprint` according to PATH) python --version @@ -15,15 +15,13 @@ pip install wheel } pip install octoprint==$OCTOPRINT_VERSION - # Temporary bugfix, to be removed after 1.8.5 is released. - sed -i 's+//,+//g,+g' /data/python/octoprint/lib/python3.9/site-packages/octoprint/static/js/app/client/base.js } # Copy OctoPrint config to persistent storage, if missing. if [ ! -f /data/config/octoprint/config.yaml ]; then if [ -f /root/config/octoprint/config.yaml ]; then mkdir -p /data/config/octoprint - # cp /root/config/octoprint/config.yaml /data/config/octoprint/config.yaml + cp /root/config/octoprint/config.yaml /data/config/octoprint/config.yaml bashio::log.notice "Default OctoPrint config copied" else bashio::log.warning "Default OctoPrint config not found" diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh index dc5527b..658f7fd 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -4,24 +4,13 @@ # Configures proxy # ============================================================================== -mkdir -p /etc/caddy/configs - -# Generate Ingress configuration +# Generate proxy configuration bashio::var.json \ interface "$(bashio::addon.ip_address)" \ port "^$(bashio::addon.ingress_port)" \ + external_port "^$(bashio::addon.port 5000)" \ ingress_entry "$(bashio::addon.ingress_entry)" \ camera_host "$(bashio::config 'camera_url')" \ | tempio \ - -template /usr/share/tempio/Caddyfile.ingress.gtpl \ - -out /etc/caddy/configs/ingress.caddy - -# Generate direct access configuration, if enabled. -if bashio::var.has_value "$(bashio::addon.port 5000)"; then - bashio::var.json \ - interface "$(bashio::addon.ip_address)" \ - port "^$(bashio::addon.port 5000)" \ - | tempio \ - -template /usr/share/tempio/Caddyfile.direct.gtpl \ - -out /etc/caddy/configs/direct.caddy -fi + -template /usr/share/tempio/Caddyfile.gtpl \ + -out /etc/caddy/Caddyfile diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl deleted file mode 100644 index 1f6971e..0000000 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.direct.gtpl +++ /dev/null @@ -1,6 +0,0 @@ -# OctoPrint WebUI -:5000 { - reverse_proxy http://127.0.0.1:80 { - header_up X-Scheme {scheme} - } -} diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl similarity index 54% rename from 3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl rename to 3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index 22ff3eb..00764b6 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.ingress.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -1,9 +1,20 @@ +{ + debug + log { + format console + output file /var/log/caddy.log + } +} + :8099 { @ingress { remote_ip 172.30.32.2 } uri strip_prefix {{ .ingress_entry }} handle { + {{ if .recovery }} + rewrite / /recovery + {{ end }} reverse_proxy @ingress 127.0.0.1:5000 { header_up X-Script-Name {{ .ingress_entry }} header_up -Origin @@ -14,3 +25,12 @@ } } } + +{{ if .external_port }} + # OctoPrint WebUI + :5000 { + reverse_proxy http://127.0.0.1:5000 { + header_up X-Scheme {scheme} + } + } +{{ end }} From f0ba54db2d6f47e47ab79292741dbf3f988d6a01 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 11 Oct 2022 16:46:40 +0200 Subject: [PATCH 68/78] Remove external_port argument --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh | 1 - .../rootfs/usr/share/tempio/Caddyfile.gtpl | 12 +++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index da53eca..7632d60 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.10.0" +version: "2022.10.01" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." 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 658f7fd..4a144c7 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -8,7 +8,6 @@ bashio::var.json \ interface "$(bashio::addon.ip_address)" \ port "^$(bashio::addon.ingress_port)" \ - external_port "^$(bashio::addon.port 5000)" \ ingress_entry "$(bashio::addon.ingress_entry)" \ camera_host "$(bashio::config 'camera_url')" \ | tempio \ diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index 00764b6..ec9c1b9 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -26,11 +26,9 @@ } } -{{ if .external_port }} - # OctoPrint WebUI - :5000 { - reverse_proxy http://127.0.0.1:5000 { - header_up X-Scheme {scheme} - } +# OctoPrint WebUI +:5000 { + reverse_proxy http://127.0.0.1:5000 { + header_up X-Scheme {scheme} } -{{ end }} +} From 92e83b73481fef2e443441e66bde19588cfe945a Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Tue, 11 Oct 2022 16:49:29 +0200 Subject: [PATCH 69/78] Change internal port to 80 --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/services.d/octoprint/run | 2 +- 3dprinter-octoprint/rootfs/etc/services.d/proxy/run | 2 +- 3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 7632d60..faa7cd5 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.10.01" +version: "2022.10.02" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run index 224c4c1..62688bb 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/octoprint/run @@ -7,4 +7,4 @@ bashio::log.info "Starting OctoPrint..." ## Run your program -exec octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 5000 --basedir /data/config/octoprint +exec octoprint serve --iknowwhatimdoing --host 127.0.0.1 --port 80 --basedir /data/config/octoprint diff --git a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run index 6be8d30..e815e97 100644 --- a/3dprinter-octoprint/rootfs/etc/services.d/proxy/run +++ b/3dprinter-octoprint/rootfs/etc/services.d/proxy/run @@ -5,7 +5,7 @@ # ============================================================================== # Wait for web server to be available -bashio::net.wait_for 5000 +bashio::net.wait_for 80 bashio::log.info "Starting proxy..." diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index ec9c1b9..148acb4 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -15,7 +15,7 @@ {{ if .recovery }} rewrite / /recovery {{ end }} - reverse_proxy @ingress 127.0.0.1:5000 { + reverse_proxy @ingress 127.0.0.1:80 { header_up X-Script-Name {{ .ingress_entry }} header_up -Origin header_up Origin 172.30.32.2 @@ -28,7 +28,7 @@ # OctoPrint WebUI :5000 { - reverse_proxy http://127.0.0.1:5000 { + reverse_proxy http://127.0.0.1:80 { header_up X-Scheme {scheme} } } From 1f9136ec262e5acccaa8c4c48f7a8199ccc115b6 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Fri, 28 Oct 2022 16:00:38 +0200 Subject: [PATCH 70/78] Update OctoPrint version, re-add adding user. --- 3dprinter-octoprint/CHANGELOG.md | 5 +++-- 3dprinter-octoprint/build.yaml | 2 +- 3dprinter-octoprint/config.yaml | 2 +- .../rootfs/etc/cont-init.d/octoprint.sh | 14 +++++++------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/3dprinter-octoprint/CHANGELOG.md b/3dprinter-octoprint/CHANGELOG.md index b8841e8..01084fc 100644 --- a/3dprinter-octoprint/CHANGELOG.md +++ b/3dprinter-octoprint/CHANGELOG.md @@ -1,4 +1,5 @@ -- Update icon to colored nozzle. -- Cleanup Caddy config. +- Update OctoPrint to 1.8.6 +- Update icon to coloured nozzle. +- Clean-up Caddy config. - Fixes to Caddy XDG paths - Change reverse proxy from nginx to Caddy \ No newline at end of file diff --git a/3dprinter-octoprint/build.yaml b/3dprinter-octoprint/build.yaml index 0caee25..28f6dc1 100644 --- a/3dprinter-octoprint/build.yaml +++ b/3dprinter-octoprint/build.yaml @@ -9,4 +9,4 @@ labels: org.opencontainers.image.description: "3DPrinter-OctoPrint addon for Home-Assistant." org.opencontainers.image.source: "https://github.com/fredrikbaberg/3dprinter-addons" args: - OCTOPRINT_VERSION: "1.8.4" + OCTOPRINT_VERSION: "1.8.6" diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index faa7cd5..1497cb8 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.10.02" +version: "2022.10.03" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index 961ea4c..c649c72 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -29,10 +29,10 @@ if [ ! -f /data/config/octoprint/config.yaml ]; then fi # TODO: Check if user exists before setting password. -# { # Make sure Ingress user for OctoPrint exists. -# bashio::log.notice "Ensure Ingress user (homeassistant) exist." -# new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo) -# octoprint --basedir /data/config/octoprint user add homeassistant --password "$new_password" --group users --group admins # 2> /dev/null -# } || { # catch -# bashio::log.warning "Failed to ensure Ingress user exists, may not be able to launch." -# } +{ # Make sure Ingress user for OctoPrint exists. + bashio::log.notice "Ensure Ingress user (homeassistant) exist." + new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo) + octoprint --basedir /data/config/octoprint user add homeassistant --password "$new_password" --group users --group admins # 2> /dev/null +} || { # catch + bashio::log.warning "Failed to ensure Ingress user exists, may not be able to launch." +} From 9d88248cf2e5fe8240a6655f5535107aa331e7e6 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Wed, 2 Nov 2022 11:04:39 +0100 Subject: [PATCH 71/78] Cleanup before testing --- 3dprinter-octoprint/Dockerfile | 2 +- 3dprinter-octoprint/config.yaml | 4 +- .../rootfs/etc/caddy/Caddyfile | 3 +- .../rootfs/etc/caddy/configs/.gitkeep | 0 .../rootfs/etc/cont-init.d/octoprint.sh | 2 +- .../rootfs/etc/cont-init.d/proxy.sh | 2 + .../rootfs/etc/nginx/includes/mime.types | 96 ------------------- .../etc/nginx/includes/proxy_params.conf | 17 ---- .../etc/nginx/includes/server_params.conf | 6 -- .../rootfs/etc/nginx/includes/ssl_params.conf | 8 -- .../rootfs/etc/nginx/includes/upstream.conf | 3 - .../rootfs/etc/nginx/nginx.conf | 51 ---------- .../rootfs/etc/nginx/servers/.gitkeep | 0 .../rootfs/etc/nginx/templates/direct.gtpl | 24 ----- .../rootfs/etc/nginx/templates/ingress.gtpl | 37 ------- .../rootfs/usr/share/tempio/Caddyfile.gtpl | 3 + 16 files changed, 12 insertions(+), 246 deletions(-) delete mode 100644 3dprinter-octoprint/rootfs/etc/caddy/configs/.gitkeep delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/includes/mime.types delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/includes/server_params.conf delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/includes/ssl_params.conf delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/includes/upstream.conf delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/nginx.conf delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/servers/.gitkeep delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl delete mode 100644 3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl diff --git a/3dprinter-octoprint/Dockerfile b/3dprinter-octoprint/Dockerfile index 2c04504..b8f40fe 100644 --- a/3dprinter-octoprint/Dockerfile +++ b/3dprinter-octoprint/Dockerfile @@ -1,6 +1,6 @@ ARG BUILD_FROM="ghcr.io/home-assistant/amd64-base-debian:bullseye" FROM ${BUILD_FROM} -ARG OCTOPRINT_VERSION="1.8.0" +ARG OCTOPRINT_VERSION="1.8.6" ENV OCTOPRINT_VERSION=${OCTOPRINT_VERSION} diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 1497cb8..fa526a5 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.10.03" +version: "2022.11.0" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -26,7 +26,9 @@ ports_description: options: camera_url: "http://b7aa59c4-camera-mjpg-streamer/" recovery: false + reverse_proxy_test: false schema: camera_url: "url?" recovery: "bool" + reverse_proxy_test: "bool" tmpfs: true diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index 39ff23e..2e38c78 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -1,3 +1,4 @@ +# This file is a placeholder and will be replaced on { debug log { @@ -5,4 +6,4 @@ output file /var/log/caddy.log } } -import configs/*.caddy +# import configs/*.caddy diff --git a/3dprinter-octoprint/rootfs/etc/caddy/configs/.gitkeep b/3dprinter-octoprint/rootfs/etc/caddy/configs/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh index c649c72..e7ea2c4 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/octoprint.sh @@ -28,7 +28,7 @@ if [ ! -f /data/config/octoprint/config.yaml ]; then fi fi -# TODO: Check if user exists before setting password. +# TODO: Check if user already exists before setting password. { # Make sure Ingress user for OctoPrint exists. bashio::log.notice "Ensure Ingress user (homeassistant) exist." new_password=$(date +%s | sha256sum | base64 | head -c 32 ; echo) diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh index 4a144c7..27cd4e8 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -10,6 +10,8 @@ bashio::var.json \ port "^$(bashio::addon.ingress_port)" \ ingress_entry "$(bashio::addon.ingress_entry)" \ camera_host "$(bashio::config 'camera_url')" \ + recovery "$(bashio::config 'recovery')" \ + reverse_proxy_test "$(bashio::config 'reverse_proxy_test')" \ | tempio \ -template /usr/share/tempio/Caddyfile.gtpl \ -out /etc/caddy/Caddyfile diff --git a/3dprinter-octoprint/rootfs/etc/nginx/includes/mime.types b/3dprinter-octoprint/rootfs/etc/nginx/includes/mime.types deleted file mode 100644 index c230212..0000000 --- a/3dprinter-octoprint/rootfs/etc/nginx/includes/mime.types +++ /dev/null @@ -1,96 +0,0 @@ -types { - text/html html htm shtml; - text/css css; - text/xml xml; - image/gif gif; - image/jpeg jpeg jpg; - application/javascript js; - application/atom+xml atom; - application/rss+xml rss; - - text/mathml mml; - text/plain txt; - text/vnd.sun.j2me.app-descriptor jad; - text/vnd.wap.wml wml; - text/x-component htc; - - image/png png; - image/svg+xml svg svgz; - image/tiff tif tiff; - image/vnd.wap.wbmp wbmp; - image/webp webp; - image/x-icon ico; - image/x-jng jng; - image/x-ms-bmp bmp; - - font/woff woff; - font/woff2 woff2; - - application/java-archive jar war ear; - application/json json; - application/mac-binhex40 hqx; - application/msword doc; - application/pdf pdf; - application/postscript ps eps ai; - application/rtf rtf; - application/vnd.apple.mpegurl m3u8; - application/vnd.google-earth.kml+xml kml; - application/vnd.google-earth.kmz kmz; - application/vnd.ms-excel xls; - application/vnd.ms-fontobject eot; - application/vnd.ms-powerpoint ppt; - application/vnd.oasis.opendocument.graphics odg; - application/vnd.oasis.opendocument.presentation odp; - application/vnd.oasis.opendocument.spreadsheet ods; - application/vnd.oasis.opendocument.text odt; - application/vnd.openxmlformats-officedocument.presentationml.presentation - pptx; - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet - xlsx; - application/vnd.openxmlformats-officedocument.wordprocessingml.document - docx; - application/vnd.wap.wmlc wmlc; - application/x-7z-compressed 7z; - application/x-cocoa cco; - application/x-java-archive-diff jardiff; - application/x-java-jnlp-file jnlp; - application/x-makeself run; - application/x-perl pl pm; - application/x-pilot prc pdb; - application/x-rar-compressed rar; - application/x-redhat-package-manager rpm; - application/x-sea sea; - application/x-shockwave-flash swf; - application/x-stuffit sit; - application/x-tcl tcl tk; - application/x-x509-ca-cert der pem crt; - application/x-xpinstall xpi; - application/xhtml+xml xhtml; - application/xspf+xml xspf; - application/zip zip; - - application/octet-stream bin exe dll; - application/octet-stream deb; - application/octet-stream dmg; - application/octet-stream iso img; - application/octet-stream msi msp msm; - - audio/midi mid midi kar; - audio/mpeg mp3; - audio/ogg ogg; - audio/x-m4a m4a; - audio/x-realaudio ra; - - video/3gpp 3gpp 3gp; - video/mp2t ts; - video/mp4 mp4; - video/mpeg mpeg mpg; - video/quicktime mov; - video/webm webm; - video/x-flv flv; - video/x-m4v m4v; - video/x-mng mng; - video/x-ms-asf asx asf; - video/x-ms-wmv wmv; - video/x-msvideo avi; -} \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf b/3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf deleted file mode 100644 index 406b739..0000000 --- a/3dprinter-octoprint/rootfs/etc/nginx/includes/proxy_params.conf +++ /dev/null @@ -1,17 +0,0 @@ -proxy_http_version 1.1; -proxy_ignore_client_abort off; -proxy_read_timeout 86400s; -proxy_redirect off; -proxy_send_timeout 86400s; -proxy_max_temp_file_size 0; - -proxy_set_header Accept-Encoding ""; -proxy_set_header Connection $connection_upgrade; -proxy_set_header Host $http_host; -proxy_set_header Upgrade $http_upgrade; -proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; -proxy_set_header X-Forwarded-Proto $scheme; -proxy_set_header X-NginX-Proxy true; -proxy_set_header X-Real-IP $remote_addr; - -proxy_set_header X-Scheme $scheme; \ No newline at end of file diff --git a/3dprinter-octoprint/rootfs/etc/nginx/includes/server_params.conf b/3dprinter-octoprint/rootfs/etc/nginx/includes/server_params.conf deleted file mode 100644 index 09c0654..0000000 --- a/3dprinter-octoprint/rootfs/etc/nginx/includes/server_params.conf +++ /dev/null @@ -1,6 +0,0 @@ -root /dev/null; -server_name $hostname; - -add_header X-Content-Type-Options nosniff; -add_header X-XSS-Protection "1; mode=block"; -add_header X-Robots-Tag none; diff --git a/3dprinter-octoprint/rootfs/etc/nginx/includes/ssl_params.conf b/3dprinter-octoprint/rootfs/etc/nginx/includes/ssl_params.conf deleted file mode 100644 index e6789cb..0000000 --- a/3dprinter-octoprint/rootfs/etc/nginx/includes/ssl_params.conf +++ /dev/null @@ -1,8 +0,0 @@ -ssl_protocols TLSv1.2 TLSv1.3; -ssl_prefer_server_ciphers off; -ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; -ssl_session_timeout 10m; -ssl_session_cache shared:SSL:10m; -ssl_session_tickets off; -ssl_stapling on; -ssl_stapling_verify on; diff --git a/3dprinter-octoprint/rootfs/etc/nginx/includes/upstream.conf b/3dprinter-octoprint/rootfs/etc/nginx/includes/upstream.conf deleted file mode 100644 index a660320..0000000 --- a/3dprinter-octoprint/rootfs/etc/nginx/includes/upstream.conf +++ /dev/null @@ -1,3 +0,0 @@ -upstream octoprint { - server 127.0.0.1:5000; -} diff --git a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf b/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf deleted file mode 100644 index 2ed0d9c..0000000 --- a/3dprinter-octoprint/rootfs/etc/nginx/nginx.conf +++ /dev/null @@ -1,51 +0,0 @@ -# Run nginx in foreground. -daemon off; - -# This is run inside Docker. -user root; - -# Pid storage location. -pid /var/run/nginx.pid; - -# Set number of worker processes. -worker_processes 1; - -# Enables the use of JIT for regular expressions to speed-up their processing. -pcre_jit on; - -# Write error log to the add-on log. -# error_log /proc/1/fd/1 error; -error_log /var/log/nginx/error.log debug; - -# Max num of simultaneous connections by a worker process. -events { - worker_connections 512; -} - -http { - include /etc/nginx/includes/mime.types; - - access_log off; - client_max_body_size 0; - default_type application/octet-stream; - gzip on; - keepalive_timeout 65; - sendfile on; - server_tokens off; - tcp_nodelay on; - tcp_nopush on; - - map $http_upgrade $connection_upgrade { - default upgrade; - '' close; - } - - # Should get port used, taken from https://stackoverflow.com/questions/60616564/how-to-configure-nginx-x-forwarded-port-to-be-the-originally-request-port - map $http_x_forwarded_port $port { - default $remote_port; - "~^(.*)$" $1; - } - - include /etc/nginx/includes/upstream.conf; - include /etc/nginx/servers/*.conf; -} diff --git a/3dprinter-octoprint/rootfs/etc/nginx/servers/.gitkeep b/3dprinter-octoprint/rootfs/etc/nginx/servers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl deleted file mode 100644 index 696df34..0000000 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/direct.gtpl +++ /dev/null @@ -1,24 +0,0 @@ -server { - listen {{ .interface }}:{{ .port }} default_server; - - # include /etc/nginx/includes/server_params.conf; - # include /etc/nginx/includes/proxy_params.conf; - - location / { - proxy_pass http://octoprint/; - 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_http_version 1.1; - - client_max_body_size 0; - } - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } -} diff --git a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl b/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl deleted file mode 100644 index a2a5eb4..0000000 --- a/3dprinter-octoprint/rootfs/etc/nginx/templates/ingress.gtpl +++ /dev/null @@ -1,37 +0,0 @@ -server { - listen {{ .interface }}:{{ .port }} default_server; - server_name $hostname; - - location / { - allow 172.30.32.2; - deny all; - - proxy_pass http://octoprint/; - proxy_pass_request_headers on; - proxy_set_header Host $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 172.30.32.2; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Scheme $scheme; - proxy_set_header X-Script-Name {{ .ingress_entry }}; - proxy_http_version 1.1; - client_max_body_size 0; - } - - location /webcam/ { - proxy_pass {{ .camera_host }}; - } - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } -} - -# The following headers/settings are currently not used. -# proxy_set_header X-Forwarded-For 172.30.32.2; # Autologin since using Home Assistant Ingress. -# proxy_set_header X-Forwarded-Server $host; -# proxy_set_header X-Forwarded-Port $port; diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index 148acb4..06c2f43 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -15,6 +15,9 @@ {{ if .recovery }} rewrite / /recovery {{ end }} + {{ if .reverse_proxy_test }} + rewrite / /reverse_proxy_test + {{ end }} reverse_proxy @ingress 127.0.0.1:80 { header_up X-Script-Name {{ .ingress_entry }} header_up -Origin From b0c40566ef40d89a828f72d6c2214fd9fa1091ca Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Wed, 2 Nov 2022 11:34:45 +0100 Subject: [PATCH 72/78] Remove recovery reverse_proxy_test flags for now --- .../rootfs/usr/share/tempio/Caddyfile.gtpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index 06c2f43..431b3f9 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -12,12 +12,12 @@ } uri strip_prefix {{ .ingress_entry }} handle { - {{ if .recovery }} - rewrite / /recovery - {{ end }} - {{ if .reverse_proxy_test }} - rewrite / /reverse_proxy_test - {{ end }} + # {{ if .recovery }} + # rewrite / /recovery + # {{ end }} + # {{ if .reverse_proxy_test }} + # rewrite / /reverse_proxy_test + # {{ end }} reverse_proxy @ingress 127.0.0.1:80 { header_up X-Script-Name {{ .ingress_entry }} header_up -Origin From 52daae2816762c7cd54c82919a5ccf635d7bfb3f Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Thu, 3 Nov 2022 00:50:29 +0100 Subject: [PATCH 73/78] Use selection for mode --- 3dprinter-octoprint/config.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index fa526a5..b32099e 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.11.0" +version: "2022.11.01" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" @@ -25,10 +25,8 @@ ports_description: 5000/tcp: Web-based interface (Not required for Ingress) options: camera_url: "http://b7aa59c4-camera-mjpg-streamer/" - recovery: false - reverse_proxy_test: false + mode: normal schema: camera_url: "url?" - recovery: "bool" - reverse_proxy_test: "bool" + mode: "list(normal|recovery|reverse_proxy_test)" tmpfs: true From 301b49b79b280b45d0dddad91d5b45e8e41d5376 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Thu, 3 Nov 2022 01:19:39 +0100 Subject: [PATCH 74/78] Use list for mode; cleanup --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/caddy/Caddyfile | 2 +- .../rootfs/etc/cont-init.d/proxy.sh | 4 ++-- .../rootfs/usr/share/tempio/Caddyfile.gtpl | 14 ++++++++------ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index b32099e..4f485c2 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.11.01" +version: "2022.11.02" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile index 2e38c78..bd7a1ab 100644 --- a/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile +++ b/3dprinter-octoprint/rootfs/etc/caddy/Caddyfile @@ -1,4 +1,4 @@ -# This file is a placeholder and will be replaced on +# This file is a placeholder and will be replaced on launch. { debug log { diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh index 27cd4e8..531e0d7 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -8,10 +8,10 @@ bashio::var.json \ interface "$(bashio::addon.ip_address)" \ port "^$(bashio::addon.ingress_port)" \ + port "^$(bashio::addon.port 5000)" \ ingress_entry "$(bashio::addon.ingress_entry)" \ camera_host "$(bashio::config 'camera_url')" \ - recovery "$(bashio::config 'recovery')" \ - reverse_proxy_test "$(bashio::config 'reverse_proxy_test')" \ + mode "$(bashio::config 'mode')" \ | tempio \ -template /usr/share/tempio/Caddyfile.gtpl \ -out /etc/caddy/Caddyfile diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index 431b3f9..3780e32 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -12,12 +12,11 @@ } uri strip_prefix {{ .ingress_entry }} handle { - # {{ if .recovery }} - # rewrite / /recovery - # {{ end }} - # {{ if .reverse_proxy_test }} - # rewrite / /reverse_proxy_test - # {{ end }} + {{ if eq .mode "recovery" }} + rewrite / /recovery + {{ else if eq .mode "reverse_proxy_test" }} + rewrite / /reverse_proxy_test + {{ else }} reverse_proxy @ingress 127.0.0.1:80 { header_up X-Script-Name {{ .ingress_entry }} header_up -Origin @@ -26,12 +25,15 @@ header_up X-Scheme {scheme} flush_interval -1 } + {{ end }} } } +{{ if .external_port }} # OctoPrint WebUI :5000 { reverse_proxy http://127.0.0.1:80 { header_up X-Scheme {scheme} } } +{{ end }} From c9427d49e9fcd6637a4f6b09699cb4e9a5bb6b0d Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Thu, 3 Nov 2022 01:26:20 +0100 Subject: [PATCH 75/78] Correction to env typo --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 4f485c2..648f49c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.11.02" +version: "2022.11.03" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." 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 531e0d7..fe534a1 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -8,7 +8,7 @@ bashio::var.json \ interface "$(bashio::addon.ip_address)" \ port "^$(bashio::addon.ingress_port)" \ - port "^$(bashio::addon.port 5000)" \ + external_port "^$(bashio::addon.port 5000)" \ ingress_entry "$(bashio::addon.ingress_entry)" \ camera_host "$(bashio::config 'camera_url')" \ mode "$(bashio::config 'mode')" \ From f89caa397e42df059b4b3ad3f363f60ed81f5797 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Thu, 3 Nov 2022 01:38:08 +0100 Subject: [PATCH 76/78] Remove external_port --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh | 1 - 3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 648f49c..e18e39c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.11.03" +version: "2022.11.04" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." 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 fe534a1..6118176 100644 --- a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -8,7 +8,6 @@ bashio::var.json \ interface "$(bashio::addon.ip_address)" \ port "^$(bashio::addon.ingress_port)" \ - external_port "^$(bashio::addon.port 5000)" \ ingress_entry "$(bashio::addon.ingress_entry)" \ camera_host "$(bashio::config 'camera_url')" \ mode "$(bashio::config 'mode')" \ diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index 3780e32..d6e33e1 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -29,11 +29,9 @@ } } -{{ if .external_port }} # OctoPrint WebUI :5000 { reverse_proxy http://127.0.0.1:80 { header_up X-Scheme {scheme} } } -{{ end }} From 81619ac20ba6d3bfb9c2a51c40feb226f4766760 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Thu, 3 Nov 2022 01:45:23 +0100 Subject: [PATCH 77/78] Fix bug in selecting mode --- 3dprinter-octoprint/config.yaml | 2 +- 3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index e18e39c..8a98c3c 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.11.04" +version: "2022.11.05" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint" diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl index d6e33e1..7a9b521 100644 --- a/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/Caddyfile.gtpl @@ -16,7 +16,7 @@ rewrite / /recovery {{ else if eq .mode "reverse_proxy_test" }} rewrite / /reverse_proxy_test - {{ else }} + {{ end }} reverse_proxy @ingress 127.0.0.1:80 { header_up X-Script-Name {{ .ingress_entry }} header_up -Origin @@ -25,7 +25,6 @@ header_up X-Scheme {scheme} flush_interval -1 } - {{ end }} } } From 3f5141b8d9d460fefa7e666eac1dd25e8175f4c6 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Thu, 3 Nov 2022 02:26:59 +0100 Subject: [PATCH 78/78] Update data before merge --- 3dprinter-octoprint/README.md | 2 ++ 3dprinter-octoprint/config.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/3dprinter-octoprint/README.md b/3dprinter-octoprint/README.md index 1148f6c..e5dcc29 100644 --- a/3dprinter-octoprint/README.md +++ b/3dprinter-octoprint/README.md @@ -1,3 +1,5 @@ # 3DPrinter-OctoPrint Provides OctoPrint as an addon to Home Assistant. + +**Note: Currently not in a ready-to-use state.** \ No newline at end of file diff --git a/3dprinter-octoprint/config.yaml b/3dprinter-octoprint/config.yaml index 8a98c3c..bfde696 100644 --- a/3dprinter-octoprint/config.yaml +++ b/3dprinter-octoprint/config.yaml @@ -1,5 +1,5 @@ name: "3DPrinter-OctoPrint" -version: "2022.11.05" +version: "2022.11.0" slug: "3dprinter-octoprint" description: "OctoPrint as an addon, no additional bells and whistles." url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint"