Pydio Cells docker + NGINX = /ws/chat 和 /ws/event 上的 404 错误
Posted
技术标签:
【中文标题】Pydio Cells docker + NGINX = /ws/chat 和 /ws/event 上的 404 错误【英文标题】:Pydio Cells docker + NGINX = 404 error on /ws/chat and /ws/event 【发布时间】:2020-07-15 14:19:47 【问题描述】:我已经使用来自 dockerhub 的 pydio/cells:2.1.1
映像设置了一个 Docker 容器。
我的docker-compose.yaml
包含以下部分:
cells:
image: pydio/cells:2.1.1
environment:
- CELLS_NO_TLS=1
- CELLS_BIND=files.redacted.dev:8080
- CELLS_EXTERNAL=https://files.redacted.dev
volumes:
- /srv/cells:/var/cells
ports:
- "8081:8080"
depends_on:
- cells_mysql
restart: unless-stopped
为了将 Cells 暴露给网络,我使用了 nginx,配置如下:
server
client_max_body_size 200M;
server_name files.redacted.dev;
location /
proxy_buffering off;
proxy_pass http://localhost:8081$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
location /ws
proxy_buffering off;
proxy_pass http://localhost:8081;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/files.redacted.dev/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/files.redacted.dev/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
server
if ($host = files.redacted.dev)
return 301 https://$host$request_uri;
# managed by Certbot
server_name files.redacted.dev;
listen 80;
listen [::]:80;
return 404; # managed by Certbot
几乎一切正常,但是我注意到当我创建一个新文件或文件夹时,我必须重新加载它才能出现在 UI 中。
查看 Firefox 的开发控制台,我看到 GET wss://files.redacted.dev/ws/chat
和 wss://files.redacted.dev/ws/event
请求出现 404 错误。
我使用以下命令在主机上进行了测试(从而绕过了 NGINX):
curl --include --no-buffer --header "Connection: Upgrade" --header "Upgrade: websocket" --header "Host: files.redacted.dev:80" --header "Origin: https://files.redacted.dev" --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" --header "Sec-WebSocket-Version: 13" http://localhost:8081/ws/chat
并且命令没有终止(我假设这意味着它是成功的......)。
看起来 NGINX 配置是问题所在。有人知道如何解决这个问题吗?
【问题讨论】:
【参考方案1】:最后它是 /ws 位置的缺少标题:
location /ws
proxy_buffering off;
proxy_pass http://localhost:8081;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
proxy_set_header Host $host; # This is what was missing!
proxy_http_version 1.1; # This might also be needed...
【讨论】:
以上是关于Pydio Cells docker + NGINX = /ws/chat 和 /ws/event 上的 404 错误的主要内容,如果未能解决你的问题,请参考以下文章
Pydio变量AJXP_DATA_PATH在CentOS中的哪些位置?