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).

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

defaults
    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 127.0.0.1
        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 127.0.0.1:5000
        redirect scheme https code 301 if !{ ssl_fc }

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

backend letsencrypt-backend
   server letsencrypt 127.0.0.1:54321

Hey!

I want to do pretty much the same than you.
I tried your haproxy config file and when I try to connect with it by just typing the IP address of the raspberry (192.168.0.xxx) I connect with the apache2 default website. I have also tried different ports (like 443, 8080, 5000 or 54321) but they did not work.
With other haproxy config files I get connected to octoprint.
Can you help me getting this to work?

(And by the way I'm a beginner regarding network technology so please don't be mad when I misunderstood your config file and when I'm missing some major basics of networks)

EDIT: 21. 7. 2019
I used the enhanced octoprint version of the haproxy config file (https://github.com/PrusaMK2Users/MK2_Tips_and_Tricks/blob/master/Enhanced-haproxy.cfg) and changed only the ports.conf of apache2 (/etc/apache2/ports.conf): I changed the port from 80 to 81 and the other port from 443 to 444.
Now I can access octoprint via the IP + port 80 (192.168.0.xxx:80) and apache2 via the IP + Port 81 (192.168.0.xxx:81)

Hello,

I am also interested in this setup, but my custom website is just an html file (nothing else). So my question is if I need to install apache2 or if I can just get away with placing the file in a specific directory and point to it somehow? Thank you in advance.