From 67f7dcf9fbc5a5431513bc02c0ca5d3a1182fd75 Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 11 Jul 2022 23:36:01 +0200 Subject: [PATCH] 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; + } }