I'm using Nginx in a docker container with built in letsencrypt support and SSL, but the principle should be the same. Here's what I've got to serve up Octoprint on a subfolder of my main domain and with a webcam (Logitech C920) working fine.
My Raspberry Pi has a static IP on 192.168.0.240
.
I can reach Octoprint on https://server.com/octoprint
& the webcam on https://server.com/octocam
This reverse proxy configuration works "out the box" with no edits required to /boot/octoprint.txt
location /octoprint/ {
proxy_pass http://192.168.0.240/;
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_set_header X-Script-Name /octoprint;
proxy_http_version 1.1;
client_max_body_size 0;
}
location /octocam/ {
proxy_pass http://192.168.0.240:8080/;
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_set_header X-Script-Name /octocam;
proxy_http_version 1.1;
client_max_body_size 0;
}
Once you've confirmed that the above two are working you can configure Octoprint in the webui with a webcam stream URL of https://server.com/octocam/?action=stream
and a snapshot URL of https://server.com/octocam/?action=snapshot
Obviously the IP of 192.168.0.240
and server.com
will be replaced by whatever you are using in your setup.
Just posting here in case anybody is struggling.