Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Serve Mercury Static Files via Nginx #468

Open
Mel3530 opened this issue Sep 22, 2024 · 0 comments
Open

Unable to Serve Mercury Static Files via Nginx #468

Mel3530 opened this issue Sep 22, 2024 · 0 comments

Comments

@Mel3530
Copy link

Mel3530 commented Sep 22, 2024

Hi,
I have a service in Docker Compose that contains JupyterHub, a VRE that spawns a container for each user's session. In the same service, Mercury is running on port 8050 using this command in thejupyterhub.conffile:

subprocess.Popen(["mercury", "run", "0.0.0.0:8050"])

And in docker-compose.yml:

jupyterhub:
    ...
    ports:
      - 8050:8050 # Mercury
      - 8888:80

Now I can access Mercury in the browser by navigating to http://localhost:8050 due to the mapping done in the Compose file. However, I want to serve Mercury through NGINX, and I have set it up like this:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
  listen 0.0.0.0:80;
  resolver 127.0.0.11 valid=30s;
  resolver_timeout 10s;

  location / {
    proxy_set_header Host $http_host;
  }

  location /webapp/ {                   
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://jupyterhub:8050/;
  }

  location /webapp/static/ {
    proxy_pass http://jupyterhub:8050/static/; 
  }

  location /hub/ {
    proxy_pass http://jupyterhub/;
    ...
    # websocket headers 
    ...
  }

  # location /webapp {
  #   try_files $uri @proxy_webapp;
  # }
  
  # location @proxy_webapp {
  #   proxy_set_header Host $http_host;
  #   proxy_redirect off;
  #   proxy_pass http://jupyterhub:8050;
  # }
  

  # location ^/static/ {  
  #   include /etc/nginx/mime.types;  
  #   autoindex on;    
  #   root   /etc/nginx/html/static/;    
  # }    
  
  # location ^/static/ {  
  #   alias /usr/local/share/jupyterhub/static/;  
  #   include /etc/nginx/mime.types;  
  #   autoindex on;    
  #   # root   /etc/nginx/html/static/;    
  # }    
...
}

The commented-out locations are previous attempts to solve the issue. As you can see in the nginx.conf, I tried to serve Mercury at the URL http://localhost/webapp/. However, I encounter a 404 error because it cannot find some static files:

2024/09/20 10:56:26 [error] 28#28: *213 open() "/etc/nginx/html/static/jupyter-syntax.css" failed (2: No such file or directory), client: 10.58.60.101, server: , request: "GET /static/jupyter-syntax.css HTTP/1.1", host: "localhost", referrer: "http://localhost/webapp/"
10.58.60.101 - - [20/Sep/2024:10:56:26 +0000] "GET /static/jupyter-syntax.css HTTP/1.1" 404 555 "http://localhost/webapp/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0" "-"
2024/09/20 10:56:26 [error] 28#28: *215 open() "/etc/nginx/html/static/jupyter-additional.css" failed (2: No such file or directory), client: 10.58.60.101, server: , request: "GET /static/jupyter-additional.css HTTP/1.1", host: "localhost", referrer: "http://localhost/webapp/"
10.58.60.101 - - [20/Sep/2024:10:56:26 +0000] "GET /static/jupyter-additional.css HTTP/1.1" 404 555 "http://localhost/webapp/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0" "-"
2024/09/20 10:56:26 [error] 28#28: *213 open() "/etc/nginx/html/static/jupyter-theme-light.css" failed (2: No such file or directory), client: 10.58.60.101, server: , request: "GET /static/jupyter-theme-light.css HTTP/1.1", host: "localhost", referrer: "http://localhost/webapp/"
10.58.60.101 - - [20/Sep/2024:10:56:26 +0000] "GET /static/jupyter-theme-light.css HTTP/1.1" 404 555 "http://localhost/webapp/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0" "-"
2024/09/20 10:56:26 [error] 28#28: *216 open() "/etc/nginx/html/static/css/2.c6cf5ff9.chunk.css" failed (2: No such file or directory), client: 10.58.60.101, server: , request: "GET /static/css/2.c6cf5ff9.chunk.css HTTP/1.1", host: "localhost", referrer: "http://localhost/webapp/"
10.58.60.101 - - [20/Sep/2024:10:56:26 +0000] "GET /static/css/2.c6cf5ff9.chunk.css HTTP/1.1" 404 555 "http://localhost/webapp/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0" "-"
10.58.60.101 - - [20/Sep/2024:10:56:26 +0000] "GET /static/css/main.9848f1b3.chunk.css HTTP/1.1" 404 555 "http://localhost/webapp/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0" "-"

I would greatly appreciate any assistance in identifying what isn't working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant