begin haproxy implementation
This commit is contained in:
45
haproxy.basic
Normal file
45
haproxy.basic
Normal file
@@ -0,0 +1,45 @@
|
||||
#Basic setup from:
|
||||
#https://community.octoprint.org/t/setting-up-octoprint-on-a-computer-running-fedora-centos-almalinux-or-rockylinux/37137/2
|
||||
[/etc/haproxy/haproxy.cfg]
|
||||
global
|
||||
chroot /var/lib/haproxy
|
||||
pidfile /var/lib/haproxy.pid
|
||||
maxconn 4000
|
||||
user haproxy
|
||||
group haproxy
|
||||
daemon
|
||||
log 127.0.0.1 local2
|
||||
# turn on stats unix socket
|
||||
stats socket /var/lib/haproxy/stats
|
||||
|
||||
# utilize system-wide crypto-policies
|
||||
ssl-default-bind-ciphers PROFILE=SYSTEM
|
||||
ssl-default-server-ciphers PROFILE=SYSTEM
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
option dontlognull
|
||||
retries 3
|
||||
option redispatch
|
||||
option http-server-close
|
||||
option forwardfor except 127.0.0.0/8
|
||||
timeout http-request 10s
|
||||
timeout queue 1m
|
||||
timeout connect 10s
|
||||
timeout client 1m
|
||||
timeout server 1m
|
||||
timeout http-keep-alive 10s
|
||||
timeout check 10s
|
||||
|
||||
frontend public
|
||||
bind :::80 v4v6
|
||||
option forwardfor except 127.0.0.1
|
||||
#use_backend INSTANCE if { path_beg /INSTANCE/ }
|
||||
default_backend octoprint
|
||||
|
||||
backend octoprint
|
||||
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
|
||||
option forwardfor
|
||||
server octoprint1 127.0.0.1:5000
|
||||
@@ -268,7 +268,7 @@ new_instance () {
|
||||
fi
|
||||
|
||||
#if we are on octopi, add in haproxy entry
|
||||
if [ $INSTALL -eq 1 ]; then
|
||||
if [ $INSTALL -gt 1 ]; then
|
||||
#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
|
||||
#add backend info, bracket with comments so we can remove later if needed. This all needs work, just slapping stuff in for now
|
||||
@@ -515,6 +515,7 @@ deb_packages() {
|
||||
-e libbsd-dev \
|
||||
-e ffmpeg \
|
||||
-e uuid-runtime\
|
||||
-e haproxy\
|
||||
| xargs apt-get install -y | log
|
||||
|
||||
#pacakges to REMOVE go here
|
||||
@@ -625,7 +626,7 @@ prepare () {
|
||||
fi
|
||||
#Fedora35
|
||||
if [ $INSTALL -eq 3 ]; then
|
||||
dnf -y install python3-devel cmake libjpeg-turbo-devel libbsd-devel libevent-devel
|
||||
dnf -y install python3-devel cmake libjpeg-turbo-devel libbsd-devel libevent-devel haproxy
|
||||
fi
|
||||
|
||||
echo "Installing OctoPrint in /home/$user/OctoPrint"
|
||||
@@ -646,6 +647,13 @@ prepare () {
|
||||
echo 'Updating config.yaml'
|
||||
sudo -u $user mkdir /home/$user/.octoprint
|
||||
sudo -u $user cp -p $SCRIPTDIR/config.basic /home/$user/.octoprint/config.yaml
|
||||
echo 'Updating haproxy'
|
||||
systemctl stop haproxy
|
||||
mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.orig
|
||||
cp $SCRIPTDIR/haproxy.basic /etc/haproxy/haproxy.cfg
|
||||
systemctl start haproxy
|
||||
systemctl enable haproxy
|
||||
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user