Replace nginx with Caddy
This commit is contained in:
parent
e802113c58
commit
16870e60e8
@ -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 \
|
||||
|
||||
@ -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"
|
||||
|
||||
1
3dprinter-octoprint/rootfs/etc/caddy/Caddyfile
Normal file
1
3dprinter-octoprint/rootfs/etc/caddy/Caddyfile
Normal file
@ -0,0 +1 @@
|
||||
import sites-enabled/*
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user