OctoPod icon indicating copy to clipboard operation
OctoPod copied to clipboard

OctoPod and Apache reverse proxy?

Open DariBer opened this issue 4 years ago • 7 comments

Has anyone here got OctoPod on iOS got to work when the OctoPrint is behind a apache reverse proxy? If anyone have a working config, please post it here.

DariBer avatar Jan 24 '21 19:01 DariBer

Hi @DariBer, I have OctoPrint running behind nginx (used as reverse proxy). The idea would be similar. You will need to have a proxy for the website and a proxy for each webcam that you have installed. I can share my setup if you want to go the nginx route. For Apache as a reverse proxy you can follow this and this guides

gdombiak avatar Jan 24 '21 20:01 gdombiak

Thanx for your sender @gdombiak, I have an apache and nginx as reverse proxy. So if you can share your config it would be great.

DariBer avatar Jan 24 '21 20:01 DariBer

Here you go. A content like this is in /etc/nginx/sites-available/default. I terminate HTTPS on the reverse proxy and use letsencrypt for my SSL certs. Authentication creds are managed via htpasswd

# Server for octopi.local
server {
    listen       5555;
    server_name  myserver.com;
    ssl    on;
    ssl_certificate    /etc/letsencrypt/live/myserver.com/fullchain.pem;
    ssl_certificate_key    /etc/letsencrypt/live/myserver.com/privkey.pem;

    location / {
        proxy_pass http://192.168.1.55/;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Scheme $scheme;
        proxy_http_version 1.1;

        auth_basic           "Protect Octopi Console";
        auth_basic_user_file /etc/apache2/.htpasswd;

        client_max_body_size 0;
    }

    location /webcam/ {
        proxy_pass http://192.168.1.55:8080/;

        auth_basic           "Protect Octopi Console";
        auth_basic_user_file /etc/apache2/.htpasswd;
    }

    location /webcam2/ {
        proxy_pass http://192.168.1.55:8081/;

        auth_basic           "Protect Octopi Console";
        auth_basic_user_file /etc/apache2/.htpasswd;
    }

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

gdombiak avatar Jan 24 '21 21:01 gdombiak

Thanx for your config :-) Will try it later tonight.

DariBer avatar Jan 25 '21 17:01 DariBer

@gdombiak I sort got it to work, but there's one thing I don't understand, the /webcam/ config, you use port 8080 and port 8081 for another webcam. I wonder where do you configure these ports on the OctoPrint?

DariBer avatar Jan 26 '21 14:01 DariBer

Port 8080 is what OctoPi uses out of the box. I created a second service that runs mjpg_streamer in port 8081 for my second camera that is hooked up to the same RPi.

gdombiak avatar Feb 07 '21 21:02 gdombiak

Hello @gdombiak , thanks for your configuration! The infos about your proxy_set_header settings helped me to solve my issues. Before OctoPod didn't show all values.

This configuration works well for me. :-)

Best regards, Oli

nauni77 avatar Mar 30 '22 07:03 nauni77