Update nginx

This commit is contained in:
Fredrik Baberg 2022-06-27 16:51:33 +02:00
parent cded609a02
commit 4982f00eb8
9 changed files with 88 additions and 60 deletions

View File

@ -22,6 +22,9 @@ RUN apt update && \
&& \
apt clean
# Remove nginx default site.
RUN rm /etc/nginx/sites-enabled/default
# Copy root filesystem
COPY rootfs /
RUN chmod +x /etc/cont-init.d/*.sh

View File

@ -1,5 +1,5 @@
name: "3DPrinter-OctoPrint"
version: "2022.6.020"
version: "2022.6.022"
slug: "3dprinter-octoprint"
description: "New instance of OctoPrint"
url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint"
@ -13,9 +13,7 @@ init: false
map:
- share:rw
options:
message: "Hello world..."
schema:
message: "str?"
ports:
5000/tcp: null
5000/tcp: 5000
ingress: true

View File

@ -1,15 +1,22 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Prepare proxy
# Prepare nginx proxy
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
bashio::log.info "Proxy cont-init.d"
bashio::log.info "nginx cont-init.d"
ingress_entry=$(bashio::addon.ingress_entry)
export ingress_entry=${ingress_entry}
tempio \
-conf /data/options.json \
-template /usr/share/tempio/ingress.conf \
-out /etc/nginx/sites-enabled/ingress.conf
tempio \
-conf /data/options.json \
-template /usr/share/tempio/webui.conf \
-out /etc/nginx/sites-enabled/webui.conf

View File

@ -0,0 +1,12 @@
#!/usr/bin/env bashio
# ==============================================================================
# Take down the S6 supervision tree when example fails
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
if [[ "$1" -ne 0 ]] && [[ "$1" -ne 256 ]]; then
bashio::log.warning "Halt add-on"
exec /run/s6/basedir/bin/halt
fi
bashio::log.info "Service restart after closing"

View File

@ -0,0 +1,8 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start nginx proxy
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
bashio::log.info "Starting NGinx..."
exec nginx

View File

@ -4,9 +4,11 @@
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
if [[ "$1" -ne 0 ]] && [[ "$1" -ne 256 ]]; then
bashio::log.warning "Halt add-on"
exec /run/s6/basedir/bin/halt
fi
# if [[ "$1" -ne 0 ]] && [[ "$1" -ne 256 ]]; then
# bashio::log.warning "Halt add-on"
# exec /run/s6/basedir/bin/halt
# fi
bashio::log.info "Service restart after closing"
# bashio::log.info "Service restart after closing"
bashio::log.notice "Finish up OctoPrint..."

View File

@ -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 0.0.0.0 --port 80 --basedir /data/config/octoprint

View File

@ -1,54 +1,29 @@
events {
worker_connections 1024;
}
server {
listen 8099;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
allow 172.30.32.2;
deny all;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
server_name _;
access_log /dev/stdout combined;
location {{ env "ingress_entry" }}/ {
proxy_pass http://127.0.0.1:80/; # 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;
}
upstream "octoprint" {
server 127.0.0.1:5000;
}
upstream "mjpg-streamer" {
server 127.0.0.1:8080;
}
server {
listen 8099;
server_name localhost;
location /octoprint/ {
proxy_pass http://octoprint/; # make sure to add trailing slash here!
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name {{ env "ingress_entry" }};
proxy_http_version 1.1;
client_max_body_size 0;
}
location /webcam/ {
proxy_pass http://mjpg-streamer/;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

View File

@ -0,0 +1,23 @@
server {
listen 5000;
server_name localhost;
location / {
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";
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;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}