Change from nginx to haproxy

This commit is contained in:
Fredrik Baberg 2022-06-27 14:59:22 +02:00
parent 00de8d054a
commit a6150173fb
6 changed files with 42 additions and 33 deletions

View File

@ -15,7 +15,7 @@ RUN apt update && \
python3-venv \
python3-dev \
build-essential \
nginx \
haproxy \
&& \
apt clean

View File

@ -1,5 +1,5 @@
name: "3DPrinter-OctoPrint"
version: "2022.6.016"
version: "2022.6.017"
slug: "3dprinter-octoprint"
description: "New instance of OctoPrint"
url: "https://github.com/fredrikbaberg/home-assistant-addons/tree/main/3dprinter-octoprint"

View File

@ -4,8 +4,6 @@
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
whoami
{ # Check if OctoPrint is installed
bashio::log.info "Check OctoPrint version..."
octoprint --version
@ -19,4 +17,5 @@ whoami
}
bashio::log.info "Install OctoPrint..."
pip install octoprint==$OCTOPRINT_VERSION
}
}
bashio::log.info "OctoPrint ready..."

View File

@ -9,10 +9,7 @@ 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
-template /usr/share/tempio/ingress.cfg \
-out /etc/haproxy/haproxy.cfg

View File

@ -0,0 +1,36 @@
global
maxconn 4096
user haproxy
group haproxy
daemon
log 127.0.0.1 local0 debug
defaults
log global
mode http
compression algo gzip
option httplog
option dontlognull
retries 3
option redispatch
option http-server-close
option forwardfor
maxconn 2000
timeout connect 5s
timeout client 15m
timeout server 15m
frontend ingress
bind *:8099
default_backend octoprint
backend octoprint
acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
http-request set-header X-Forwarded-Proto https if { ssl_fc }
http-request set-header X-Forwarded-Proto http if !{ ssl_fc }
option forwardfor
server octoprint1 127.0.0.1:5000
errorfile 503 /etc/haproxy/errors/503.http

View File

@ -1,23 +0,0 @@
upstream "octoprint" {
server 127.0.0.1:5000;
}
server {
listen 8099;
allow 172.30.32.2;
deny all;
location / {
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;
}
}