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 PYTHONUSERBASE=/data/python/octoprint
|
||||||
ENV PATH=/data/python/octoprint/bin:${PATH}
|
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
|
# Install dependencies
|
||||||
RUN apt update && \
|
RUN apt update && \
|
||||||
apt install -y \
|
apt install -y \
|
||||||
@ -17,7 +27,8 @@ RUN apt update && \
|
|||||||
python3-dev \
|
python3-dev \
|
||||||
python3-wheel \
|
python3-wheel \
|
||||||
build-essential \
|
build-essential \
|
||||||
nginx \
|
caddy \
|
||||||
|
# nginx \
|
||||||
# Extras.
|
# Extras.
|
||||||
# ffmpeg \
|
# ffmpeg \
|
||||||
# avrdude \
|
# avrdude \
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: "3DPrinter-OctoPrint"
|
name: "3DPrinter-OctoPrint"
|
||||||
version: "2022.9.015"
|
version: "2022.9.016"
|
||||||
slug: "3dprinter-octoprint"
|
slug: "3dprinter-octoprint"
|
||||||
description: "OctoPrint as an addon, no additional bells and whistles."
|
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-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
|
#!/usr/bin/with-contenv bashio
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Add-on: 3dprinter-octoprint
|
# Add-on: 3dprinter-octoprint
|
||||||
# Configures NGINX
|
# Configures proxy
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# Generate Ingress configuration
|
# Generate Ingress configuration
|
||||||
@ -11,8 +11,8 @@ bashio::var.json \
|
|||||||
ingress_entry "$(bashio::addon.ingress_entry)" \
|
ingress_entry "$(bashio::addon.ingress_entry)" \
|
||||||
camera_host "$(bashio::config 'camera_url')" \
|
camera_host "$(bashio::config 'camera_url')" \
|
||||||
| tempio \
|
| tempio \
|
||||||
-template /etc/nginx/templates/ingress.gtpl \
|
-template /usr/share/tempio/Caddyfile.ingress.gtpl \
|
||||||
-out /etc/nginx/servers/ingress.conf
|
-out /etc/caddy/sites-enabled/ingress
|
||||||
|
|
||||||
# Generate direct access configuration, if enabled.
|
# Generate direct access configuration, if enabled.
|
||||||
if bashio::var.has_value "$(bashio::addon.port 5000)"; then
|
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)" \
|
interface "$(bashio::addon.ip_address)" \
|
||||||
port "^$(bashio::addon.port 5000)" \
|
port "^$(bashio::addon.port 5000)" \
|
||||||
| tempio \
|
| tempio \
|
||||||
-template /etc/nginx/templates/direct.gtpl \
|
-template /usr/share/tempio/Caddyfile.direct.gtpl \
|
||||||
-out /etc/nginx/servers/direct.conf
|
-out /etc/caddy/sites-enabled/direct
|
||||||
fi
|
fi
|
||||||
@ -1,9 +1,7 @@
|
|||||||
#!/usr/bin/execlineb -S0
|
#!/usr/bin/execlineb -S0
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Add-on: 3dprinter-octoprint
|
# 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
|
#!/usr/bin/with-contenv bashio
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Add-on: 3dprinter-octoprint
|
# Add-on: 3dprinter-octoprint
|
||||||
# Runs the Nginx daemon
|
# Runs the reverse proxy.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# Wait for web server to be available
|
# Wait for web server to be available
|
||||||
bashio::net.wait_for 5000
|
bashio::net.wait_for 5000
|
||||||
|
|
||||||
bashio::log.info "Starting NGinx..."
|
bashio::log.info "Starting proxy..."
|
||||||
exec nginx
|
|
||||||
|
caddy start --config /etc/caddy/Caddyfile --watch
|
||||||
@ -11,6 +11,7 @@ folder:
|
|||||||
generated: /tmp/octoprint/generated
|
generated: /tmp/octoprint/generated
|
||||||
timelapse_tmp: /tmp/octoprint/timelapse/tmp
|
timelapse_tmp: /tmp/octoprint/timelapse/tmp
|
||||||
server:
|
server:
|
||||||
|
allowFraming: true
|
||||||
commands:
|
commands:
|
||||||
serverRestartCommand: /scripts/octoprint_restart.sh
|
serverRestartCommand: /scripts/octoprint_restart.sh
|
||||||
systemRestartCommand: /scripts/system_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