nerfstudio-project / viser

Web-based 3D visualization + Python
https://viser.studio/latest
Apache License 2.0
596 stars 31 forks source link

Serve ns-viewer over HTTPS #210

Open hadillivvy opened 1 month ago

hadillivvy commented 1 month ago

I have a script on the production server that launches an ns-viewer process on demand and the ns-viewer command exposes the viewer on localhost port 7007. However, this connection is always HTTP and not HTTPS. I tried different ways to secure the connection but nothing is working. Any advice on how to achieve this?

brentyi commented 1 month ago

Hello!

A reverse proxy should work here, for example via NGINX:

If you also need certificates, Let's Encrypt is popular: https://letsencrypt.org/

hadillivvy commented 1 month ago

Hi @brentyi

I tried the nginx reverse proxy approach and it worked but the problem is that I'm planning on launching multiple ns-viewer processes on the server and so I need to target the port in the URL as well and that's not working with HTTPS using the nginx reverse proxy approach. Is there a way to do it on my server like https://viewer.nerf.studio/ where I give it maybe the ws url or something and it displays the right nerf instead of giving it the port?

Zunhammer commented 1 month ago

Hi, I'm not sure if I get your problem right but nginx is able to work with different ports on the same server. You simply need to provide multiple configs listening to the different ports and then in the "proxy_pass" add the port of the ns-viewer instance. E.g.

server { # simple reverse-proxy listen 7007; [...] location / { proxy_pass http://127.0.0.1:7007; } }

and the next one like

server { # simple reverse-proxy listen 7008; [...] location / { proxy_pass http://127.0.0.1:7008; } }