OctoPrint + website running on Apache2


Hello everyone!

I'm trying to set up OctoPrint together with apache2 web server on my Raspberry Pi 3. I've already tried to set up everything in haproxy, but I just don't know how to set it up properly. **I know, that it may not be a good idea, but I still want to try that out :smiley: **

I would like to set up everythig to work like that:

domain.com >> apache2 virtual host domain.com
sub.domain.com >> apache2 virtual host sub.domain.com
3d.domain.com >> OctoPrint

Below is my current haproxy config file. I was somehow able to correctly set up https redirect with Let's Encrypt certificate (took me a night, but works).

        maxconn 512
        user haproxy
        group haproxy
        log local1 debug
        tune.ssl.default-dh-param 2048

    option forwardfor
    option http-server-close
        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
    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
    reqadd X-Forwarded-Proto:\ http
    default_backend octoprint
        option forwardfor except
        use_backend webcam if { path_beg /webcam/ }
        default_backend octoprint

frontend www-https
    bind *:443 ssl crt /etc/haproxy/certs/cert.pem
    reqadd X-Forwarded-Proto:\ https
    http-request set-header X-SSL %[ssl_fc]
    acl letsencrypt-acl path_beg /.well-known/acme-challenge/
    use_backend letsencrypt-backend if letsencrypt-acl
    default_backend octoprint

backend octoprint
        server octoprint1
        redirect scheme https code 301 if !{ ssl_fc }

backend webcam
        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
        server webcam1
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

backend letsencrypt-backend
   server letsencrypt