你好,我想马上说的是,我一直在使用docker-compose和nginx没有这么长时间,对不起,如果你会看到一些错误,从我自己的。
我遇到了nginx设置的问题,现在几天都解决不了。我的任务是使用docker-compose连接到我本地comp上的另一个容器。在第一个容器中,我使用反向代理,将我的请求转发到另一个容器,并运行xboxyterlab。但当我连接到xboxyter时,我总是得到**502 Bad Gateway**,但这两个容器运行。也许xboxyter不需要,但是在反向代理中的应用程序
我假设问题出在我的docker-compose网络上,但我使用了不同的方法,但不幸的是,我总是遇到同样的问题
所以我的docker-compose看起来像这样
version: '3.8'
services:
jupyterlab:
build:
...
volumes:
- ...
ports:
- "8888:8888"
networks:
- new-networks
nginx:
build:
...
ports:
- "80:80"
networks:
- new-networks
networks:
new-networks:
driver: bridge
ipam:
driver: default
config:
- subnet: 127.0.0.0/16
字符串
在Jupyter的Dockerfile中,我有EXPOSE 8888
在nginx容器中,我使用sites-enable文件名为domain(所以127.0.0.1),而不是nginx.conf(但在这个任务中,我也使用了nginx.conf,但我得到了相同的错误)
我在nginx中的设置(文件名:127.0.0.1):
upstream backend {
server 127.0.0.1:8888;
}
server {
listen 80;
listen [::]:80;
root /var/www/127.0.0.1/html;
index index.html index.htm index.nginx-debian.html;
server_name 127.0.0.1 www.127.0.0.1 ;
location /jupyter {
proxy_pass http://backend/;
}
location /status {
default_type application/json;
return 200 '{"status": "All good"}';
}
}
型
我尝试在upstream和proxy_pass中使用另一个域(如172...)。尝试set_headers。更改ufw(但不太多)。但总是相同的错误(502)。
我在nginx中检查了我的日志(如果在upstream中我写127.0.0.1:8888),它得到:
connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: 127.0.0.1, request: "GET /jupyter HTTP/1.1", upstream: "http://127.0.0.1:8888/", host: "127.0.0.1"
型
当我写172...:8888 un upstream(here I got 404 error):
*2 open() "/var/www/127.0.0.1/html/lab" failed (2: No such file or directory), client: 172.18.0.1, server: 127.0.0.1, request: "GET /lab? HTTP/1.1", host: "127.0.0.1"
型
upd.2
我也试过用途:
upstream backend {
server jupyterlab:8888;
型
但我只得到404
*6 open() "/var/www/127.0.0.1/html/lab" failed (2: No such file or directory), client: 172.20.0.1, server: 127.0.0.1, request: "GET /lab? HTTP/1.1", host: "127.0.0.1"
型
upd.3
现在我改变了我的nginx conf文件,现在get another 404不像往常一样。
upstream jupyter {
server jupyterlab:8888;
}
server {
listen nginx:80;
server_name 127.0.0.1 www.127.0.0.1 ;
location /jupyter {
proxy_pass http://jupyter;
}
location /ping {
default_type application/json;
return 200 '{"status": "All good"}';
}
}
型
在日志文件中,我得到了新的错误:
2023/11/01 12:52:08 [error] 25#25: *3 open() "/usr/share/nginx/html/static/style/index.css" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/style/index.css?v=30372e3246a801d662cf9e3f9dd656fa192eebde9054a2282449fe43919de9f0ee9b745d7eb49d3b0a5e56357912cc7d776390eddcab9dac85b77bdb17b4bdae HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 26#26: *2 open() "/usr/share/nginx/html/static/style/bootstrap-theme.min.css" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/style/bootstrap-theme.min.css?v=8b2f045cb5b4d5ad346f6e816aa2566829a4f5f2783ec31d80d46a57de8ac0c3d21fe6e53bcd8e1f38ac17fcd06d12088bc9b43e23b5d1da52d10c6b717b22b3 HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 26#26: *1 open() "/usr/share/nginx/html/static/style/bootstrap.min.css" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/style/bootstrap.min.css?v=0e8a7fbd6de23ad6b27ab95802a0a0915af6693af612bc304d83af445529ce5d95842309ca3405d10f538d45c8a3a261b8cff78b4bd512dd9effb4109a71d0ab HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 27#27: *4 open() "/usr/share/nginx/html/static/style/index.css" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/style/index.css?v=30372e3246a801d662cf9e3f9dd656fa192eebde9054a2282449fe43919de9f0ee9b745d7eb49d3b0a5e56357912cc7d776390eddcab9dac85b77bdb17b4bdae HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 25#25: *3 open() "/usr/share/nginx/html/static/logo/logo.png" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/logo/logo.png?v=a2a176ee3cee251ffddf5fa21fe8e43727a9e5f87a06f9c91ad7b776d9e9d3d5e0159c16cc188a3965e00375fb4bc336c16067c688f5040c0c2d4bfdb852a9e4 HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 26#26: *2 open() "/usr/share/nginx/html/static/style/bootstrap-theme.min.css" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/style/bootstrap-theme.min.css?v=8b2f045cb5b4d5ad346f6e816aa2566829a4f5f2783ec31d80d46a57de8ac0c3d21fe6e53bcd8e1f38ac17fcd06d12088bc9b43e23b5d1da52d10c6b717b22b3 HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 25#25: *3 open() "/usr/share/nginx/html/static/style/bootstrap.min.css" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/style/bootstrap.min.css?v=0e8a7fbd6de23ad6b27ab95802a0a0915af6693af612bc304d83af445529ce5d95842309ca3405d10f538d45c8a3a261b8cff78b4bd512dd9effb4109a71d0ab HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 26#26: *2 open() "/usr/share/nginx/html/static/style/bootstrap-theme.min.css" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/style/bootstrap-theme.min.css?v=8b2f045cb5b4d5ad346f6e816aa2566829a4f5f2783ec31d80d46a57de8ac0c3d21fe6e53bcd8e1f38ac17fcd06d12088bc9b43e23b5d1da52d10c6b717b22b3 HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 27#27: *4 open() "/usr/share/nginx/html/static/style/index.css" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/style/index.css?v=30372e3246a801d662cf9e3f9dd656fa192eebde9054a2282449fe43919de9f0ee9b745d7eb49d3b0a5e56357912cc7d776390eddcab9dac85b77bdb17b4bdae HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/01 12:52:08 [error] 26#26: *1 open() "/usr/share/nginx/html/static/logo/logo.png" failed (2: No such file or directory), client: 172.24.0.1, server: 127.0.0.1, request: "GET /static/logo/logo.png?v=a2a176ee3cee251ffddf5fa21fe8e43727a9e5f87a06f9c91ad7b776d9e9d3d5e0159c16cc188a3
型
如果我在Jupyter server
中转换,我将得到basic 404 error。日志将如下所示:
2023/11/02 11:15:54 [error] 25#25: *2 open() "/usr/share/nginx/html/lab" failed (2: No such file or directory), client: 172.25.0.1, server: 127.0.0.1, request: "GET /lab HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/jupyter"
2023/11/02 11:15:54 [error] 25#25: *2 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.25.0.1, server: 127.0.0.1, request: "GET /favicon.ico HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.14/lab"
2023/11/02 11:19:37 [error] 24#24: *3 open() "/usr/share/nginx/html/lab" failed (2: No such file or directory), client: 172.25.0.1, server: 127.0.0.1, request: "GET /lab HTTP/1.1", host: "196.172.12.14", referrer: "http://196.172.12.144/jupyter"
型
如果你能帮我
2条答案
按热度按时间gstyhher1#
字符串
应该可以解决这个问题。在
docker-compose
中,服务可以使用服务名来命名。bweufnob2#
无论如何我关闭这个问题,现在我有一个不同的问题,而不是写在这个主题。
这个问题是在我的nginx conf中,斜杠放错了位置,路径也没有完全拼出来。正如@Andromeda所说,我需要在我的
upstream
中使用服务名称。在位置中,我必须使用更详细的斜杠路径。字符串