add haproxy1.x versions
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#Basic setup from:
|
#Basic setup from:
|
||||||
#https://community.octoprint.org/t/setting-up-octoprint-on-a-computer-running-fedora-centos-almalinux-or-rockylinux/37137/2
|
#https://community.octoprint.org/t/setting-up-octoprint-on-a-computer-running-fedora-centos-almalinux-or-rockylinux/37137/2
|
||||||
[/etc/haproxy/haproxy.cfg]
|
|
||||||
global
|
global
|
||||||
maxconn 4000
|
maxconn 4000
|
||||||
user haproxy
|
user haproxy
|
||||||
@@ -31,6 +31,5 @@ frontend public
|
|||||||
default_backend octoprint
|
default_backend octoprint
|
||||||
|
|
||||||
backend octoprint
|
backend octoprint
|
||||||
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
|
|
||||||
option forwardfor
|
option forwardfor
|
||||||
server octoprint1 127.0.0.1:5000
|
server octoprint1 127.0.0.1:5000
|
||||||
31
haxproxy1x.basic
Normal file
31
haxproxy1x.basic
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
global
|
||||||
|
maxconn 4096
|
||||||
|
user haproxy
|
||||||
|
group haproxy
|
||||||
|
daemon
|
||||||
|
log 127.0.0.1 local0 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
|
||||||
|
option forwardfor except 127.0.0.1
|
||||||
|
#use_backend webcam if { path_beg /webcam/ }
|
||||||
|
default_backend octoprint
|
||||||
|
|
||||||
|
backend octoprint
|
||||||
|
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
|
||||||
|
option forwardfor
|
||||||
|
server octoprint1 127.0.0.1:5000
|
||||||
@@ -268,12 +268,17 @@ new_instance () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#if we are on octopi, add in haproxy entry
|
#if we are on octopi, add in haproxy entry
|
||||||
|
#get haproxy version
|
||||||
|
HAversion=$(haproxy -v | sed -n 's/^.*version \([0-9]\).*/\1/p')
|
||||||
if [ $INSTALL -gt 1 ]; then
|
if [ $INSTALL -gt 1 ]; then
|
||||||
#find frontend line, do insert
|
#find frontend line, do insert
|
||||||
sed -i "/option forwardfor except 127.0.0.1/a\ use_backend $INSTANCE if { path_beg /$INSTANCE/ }" /etc/haproxy/haproxy.cfg
|
sed -i "/option forwardfor except 127.0.0.1/a\ use_backend $INSTANCE if { path_beg /$INSTANCE/ }" /etc/haproxy/haproxy.cfg
|
||||||
#add backend info, bracket with comments so we can remove later if needed. This all needs work, just slapping stuff in for now
|
|
||||||
echo "#$INSTANCE start" >> /etc/haproxy/haproxy.cfg
|
echo "#$INSTANCE start" >> /etc/haproxy/haproxy.cfg
|
||||||
echo "backend $INSTANCE" >> /etc/haproxy/haproxy.cfg
|
echo "backend $INSTANCE" >> /etc/haproxy/haproxy.cfg
|
||||||
|
if [ $HAversion -gt 1 ]; then
|
||||||
|
echo " option forwardfor" >> /etc/haproxy/haproxy.cfg
|
||||||
|
echo " server octoprint1 127.0.0.1:$PORT" >> /etc/haproxy/haproxy.cfg
|
||||||
|
else
|
||||||
echo " reqrep ^([^\ :]*)\ /$INSTANCE/(.*) \1\ /\2" >> /etc/haproxy/haproxy.cfg
|
echo " reqrep ^([^\ :]*)\ /$INSTANCE/(.*) \1\ /\2" >> /etc/haproxy/haproxy.cfg
|
||||||
echo " option forwardfor" >> /etc/haproxy/haproxy.cfg
|
echo " option forwardfor" >> /etc/haproxy/haproxy.cfg
|
||||||
echo " server octoprint1 127.0.0.1:$PORT" >> /etc/haproxy/haproxy.cfg
|
echo " server octoprint1 127.0.0.1:$PORT" >> /etc/haproxy/haproxy.cfg
|
||||||
@@ -281,9 +286,11 @@ new_instance () {
|
|||||||
echo " reqadd X-Scheme:\ https if needs_scheme { ssl_fc }" >> /etc/haproxy/haproxy.cfg
|
echo " reqadd X-Scheme:\ https if needs_scheme { ssl_fc }" >> /etc/haproxy/haproxy.cfg
|
||||||
echo " reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }" >> /etc/haproxy/haproxy.cfg
|
echo " reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }" >> /etc/haproxy/haproxy.cfg
|
||||||
echo " reqadd X-Script-Name:\ /$INSTANCE" >> /etc/haproxy/haproxy.cfg
|
echo " reqadd X-Script-Name:\ /$INSTANCE" >> /etc/haproxy/haproxy.cfg
|
||||||
|
fi
|
||||||
echo "#$INSTANCE stop" >> /etc/haproxy/haproxy.cfg
|
echo "#$INSTANCE stop" >> /etc/haproxy/haproxy.cfg
|
||||||
#restart haproxy
|
#restart haproxy
|
||||||
sudo systemctl restart haproxy.service
|
sudo systemctl restart haproxy.service
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
main_menu
|
main_menu
|
||||||
@@ -649,8 +656,14 @@ prepare () {
|
|||||||
sudo -u $user cp -p $SCRIPTDIR/config.basic /home/$user/.octoprint/config.yaml
|
sudo -u $user cp -p $SCRIPTDIR/config.basic /home/$user/.octoprint/config.yaml
|
||||||
echo 'Updating haproxy'
|
echo 'Updating haproxy'
|
||||||
systemctl stop haproxy
|
systemctl stop haproxy
|
||||||
|
#get haproxy version
|
||||||
|
HAversion=$(haproxy -v | sed -n 's/^.*version \([0-9]\).*/\1/p')
|
||||||
mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.orig
|
mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.orig
|
||||||
cp $SCRIPTDIR/haproxy.basic /etc/haproxy/haproxy.cfg
|
if [ $HAversion -gt 1 ]; then
|
||||||
|
cp $SCRIPTDIR/haproxy2.basic /etc/haproxy/haproxy.cfg
|
||||||
|
else
|
||||||
|
cp $SCRIPTDIR/haproxy1.basic /etc/haproxy/haproxy.cfg
|
||||||
|
fi
|
||||||
systemctl start haproxy
|
systemctl start haproxy
|
||||||
systemctl enable haproxy
|
systemctl enable haproxy
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user