NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
Achilless
V2EX  ›  NGINX

nginx 代理 websocket 出现 404 错误

  •  
  •   Achilless · Nov 4, 2019 · 3910 views
    This topic created in 2413 days ago, the information mentioned may be changed or developed.

    部署的是 django,uwsgi。websocket 用的 channels 其他功能正常,只有 websocket 报 404 错误,

    具体配置文件和代码我放在了博客: https://www.ksprd.top/blog/46/

    有没有趟过坑的大佬~

    5 replies    2019-11-04 14:44:08 +08:00
    lazyfighter
        1
    lazyfighter  
       Nov 4, 2019
    问问题贴个博客是什么鬼啊,404 找不到呗
    Achilless
        2
    Achilless  
    OP
       Nov 4, 2019
    @lazyfighter 放代码呗,所以问题就是为啥 404 呗
    anthoy
        3
    anthoy  
       Nov 4, 2019
    我使用是用 uwsgi 启动 django,daphne 启动 django-channel,两个使用不同的端口,nginx 反向代理 /和 /ssh,正常使用
    你这里的可能是这个:
    ```bash
    location /ssh {
    uwsgi_pass 127.0.0.1:8080;
    include /opt/clic_env/plat/uwsgi_params;
    ```
    你确定你的 uwsgi 同时启动了 django 和 django-channels ?你可以使用尝试不使用 uwsgi_pass 转发 websocket 或者不用 nginx,直接调试下 uwsgi
    37Y37
        4
    37Y37  
       Nov 4, 2019
    nginx 缺少了这个配置

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

    另外看你写的 webssh,推荐一下: https://ops-coffee.cn/s/a3eJjVTtuUjzwyk21nTBqQ
    Achilless
        5
    Achilless  
    OP
       Nov 4, 2019
    @anthoy 感谢,才知道原来还要单独起一个 websocket 进程。。所以那就是 django 默认的服务器是两个都打开的。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2695 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:51 · PVG 23:51 · LAX 08:51 · JFK 11:51
    ♥ Do have faith in what you're doing.