From 294cca47c65f0d691c3ff36507a60c53e64f119b Mon Sep 17 00:00:00 2001 From: Fredrik Baberg Date: Mon, 27 Jun 2022 02:13:20 +0200 Subject: [PATCH] Add nginx --- .../rootfs/etc/cont-init.d/proxy.sh | 18 +++++++++++++++ .../rootfs/usr/share/tempio/ingress.conf | 23 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh create mode 100644 3dprinter-octoprint/rootfs/usr/share/tempio/ingress.conf diff --git a/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh new file mode 100644 index 0000000..49d1dee --- /dev/null +++ b/3dprinter-octoprint/rootfs/etc/cont-init.d/proxy.sh @@ -0,0 +1,18 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Prepare proxy +# s6-overlay docs: https://github.com/just-containers/s6-overlay +# ============================================================================== + +bashio::log.info "Proxy cont-init.d" + +ingress_entry=$(bashio::addon.ingress_entry) +export ingress_entry=${ingress_entry} + +# Make sure output folder exists. +mkdir -p /etc/nginx/http.d/ + +tempio \ + -conf /data/options.json \ + -template /usr/share/tempio/ingress.conf \ + -out /etc/nginx/http.d/ingress.conf diff --git a/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.conf b/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.conf new file mode 100644 index 0000000..6dab0e0 --- /dev/null +++ b/3dprinter-octoprint/rootfs/usr/share/tempio/ingress.conf @@ -0,0 +1,23 @@ +upstream "octoprint" { + server 127.0.0.1:5000; +} + +server { + listen 8099; + allow 172.30.32.2; + deny all; + + location /{{ env "ingress_entry" }}/ { + proxy_pass http://octoprint/; # make sure to add trailing slash here! + proxy_set_header Host $http_host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Scheme $scheme; + proxy_set_header X-Script-Name /{{ env "ingress_entry" }}; + proxy_http_version 1.1; + + client_max_body_size 0; + } +} \ No newline at end of file