Skip to content

Instantly share code, notes, and snippets.

@tofarley
Created January 10, 2019 07:36
Show Gist options
  • Save tofarley/2b51f814b8d24c4521588d5dff20fc72 to your computer and use it in GitHub Desktop.
Save tofarley/2b51f814b8d24c4521588d5dff20fc72 to your computer and use it in GitHub Desktop.
global
maxconn 4096
user haproxy
group haproxy
log 127.0.0.1 local1 debug
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
option http-server-close
option forwardfor
maxconn 2000
timeout connect 5s
timeout client 15min
timeout server 15min
frontend public
bind :::80 v4v6
bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem
option forwardfor except 127.0.0.1
use_backend webcam if { path_beg /webcam/ }
use_backend cncjs if { path_beg /cncjs/ }
default_backend octoprint
backend octoprint
acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
reqadd X-Scheme:\ https if needs_scheme { ssl_fc }
reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }
option forwardfor
server octoprint1 127.0.0.1:5000
errorfile 503 /etc/haproxy/errors/503-no-octoprint.http
backend webcam
reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2
server webcam1 127.0.0.1:8080
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
backend cncjs
reqrep ^([^\ :]*)\ /cncjs/(.*) \1\ /\2
option httpclose
server cncjs1 127.0.0.1:8000
errorfile 503 /etc/haproxy/errors/503-no-cncjs.http
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment