Jattie van der Linde

Shoe string engineering

User Tools

Site Tools


projects:3dprint:octoprint

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projects:3dprint:octoprint [2023/05/18 13:26] – [Autostart Octoprint as a Linux Service] jattieprojects:3dprint:octoprint [2023/05/18 19:26] (current) – ↷ Links adapted because of a move operation jattie
Line 2: Line 2:
  
 <WRAP center round info 60%> <WRAP center round info 60%>
-The long way is for if you care about the technical steps and want to reproduce it yourself. See the [[projects:3dprint:octoprint_image|short way to just get the LXC Octoprint image]] and get up and running as easy as possible.+The long way is for if you care about the technical steps and want to reproduce it yourself. See the [[projects:3dprint:octoprint_short|short way to just get the LXC Octoprint image]] and get up and running as easy as possible.
 </WRAP> </WRAP>
  
Line 539: Line 539:
  
 </cli> </cli>
 +
 +===== Advanced Features =====
 +
 +==== Enable .local network access ====
 +
 +to resolve the machine name with octo.local we need the avahi service.
 +
 +  * sudo apt install avahi-daemon
 +  * systemctl restart avahi-daemon
 +  * systemctl status avahi-daemon
 +
 +
 +
 +==== Make everything accessible on port 80 ====
 +
 +  * install haproxy
 +  * configure haproxy
 +  * restart the service
 +
 +=== Install ===
 +
 +<cli>
 +(venv) octo@octo:~$ sudo apt install haproxy
 +Reading package lists... Done
 +Building dependency tree... Done
 +Reading state information... Done
 +</cli>
 +
 +=== Config ===
 +
 +<cli>
 +(venv) octo@octo:~$ sudo nano /etc/haproxy/haproxy.cfg
 +</cli>
 +
 +<code apache haproxy.cfg>
 +global
 +        log /dev/log    local0
 +        log /dev/log    local1 notice
 +        chroot /var/lib/haproxy
 +        stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
 +        stats timeout 30s
 +        user haproxy
 +        group haproxy
 +        daemon
 +
 +        # Default SSL material locations
 +        ca-base /etc/ssl/certs
 +        crt-base /etc/ssl/private
 +
 +        # See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
 +        ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
 +        ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
 +        ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
 +
 +defaults
 +        log     global
 +        mode    http
 +        option  httplog
 +        option  dontlognull
 +        timeout connect 5000
 +        timeout client  50000
 +        timeout server  50000
 +        errorfile 400 /etc/haproxy/errors/400.http
 +        errorfile 403 /etc/haproxy/errors/403.http
 +        errorfile 408 /etc/haproxy/errors/408.http
 +        errorfile 500 /etc/haproxy/errors/500.http
 +        errorfile 502 /etc/haproxy/errors/502.http
 +        errorfile 503 /etc/haproxy/errors/503.http
 +        errorfile 504 /etc/haproxy/errors/504.http
 +
 +frontend public
 +        bind :::80 v4v6
 +        use_backend webcam if { path_beg /webcam/ }
 +        default_backend octoprint
 +
 +backend octoprint
 +        option forwardfor
 +        server octoprint1 127.0.0.1:5000
 +
 +backend webcam
 +        http-request replace-path /webcam/(.*)   /\1
 +        server webcam1  127.0.0.1:8080
 +</code>
 +
 +  * Restart the service
 +  * Check the status after the edits and restart
 +
 +<cli>
 +(venv) octo@octo:~$ sudo systemctl restart haproxy
 +(venv) octo@octo:~$ sudo systemctl status haproxy
 +● haproxy.service - HAProxy Load Balancer
 +     Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
 +     Active: active (running) since Thu 2023-05-18 13:43:46 UTC; 7s ago
 +       Docs: man:haproxy(1)
 +             file:/usr/share/doc/haproxy/configuration.txt.gz
 +    Process: 16750 ExecStartPre=/usr/sbin/haproxy -Ws -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)
 +   Main PID: 16752 (haproxy)
 +      Tasks: 9 (limit: 9209)
 +     Memory: 138.4M
 +        CPU: 239ms
 +     CGroup: /system.slice/haproxy.service
 +             ├─16752 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
 +             └─16754 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
 +
 +May 18 13:43:46 octo haproxy[10866]: [NOTICE]   (10866) : haproxy version is 2.4.22-0ubuntu0.22.04.1
 +May 18 13:43:46 octo haproxy[10866]: [NOTICE]   (10866) : path to executable is /usr/sbin/haproxy
 +May 18 13:43:46 octo haproxy[10866]: [ALERT]    (10866) : Current worker #1 (10868) exited with code 143 (Terminated)
 +May 18 13:43:46 octo haproxy[10866]: [WARNING]  (10866) : All workers exited. Exiting... (0)
 +May 18 13:43:46 octo systemd[1]: haproxy.service: Deactivated successfully.
 +May 18 13:43:46 octo systemd[1]: Stopped HAProxy Load Balancer.
 +May 18 13:43:46 octo systemd[1]: haproxy.service: Consumed 4.332s CPU time.
 +May 18 13:43:46 octo systemd[1]: Starting HAProxy Load Balancer...
 +May 18 13:43:46 octo haproxy[16752]: [NOTICE]   (16752) : New worker #1 (16754) forked
 +May 18 13:43:46 octo systemd[1]: Started HAProxy Load Balancer.
 +(venv) octo@octo:~$
 +
 +</cli>
 +
 +We should now be able to access the server on the standard port 80, i.e. no port specification required.
  
 ==== Setting up SSH access to your container ==== ==== Setting up SSH access to your container ====
projects/3dprint/octoprint.1684416367.txt.gz · Last modified: 2023/05/18 13:26 by jattie