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

Fix: Cross origin websockets not allowed #463

Merged
merged 1 commit into from
Aug 22, 2023
Merged

Conversation

Ansen
Copy link
Contributor

@Ansen Ansen commented Aug 22, 2023

环境:

Docker-compose + nginx (https) 反代

配置信息

Docker 环境变量配置:

      - DOMAIN=qiandao.example.com:8443
      - REDISCLOUD_URL=redis://redis:6379
      - PBKDF2_ITERATIONS=400
      - AES_KEY=Xx****xX
      - COOKIE_SECRET=Xx****xX

Nginx 配置:

    location / {
        proxy_http_version 1.1;
        proxy_connect_timeout 60s;
        proxy_read_timeout 5400s;
        proxy_send_timeout 5400s;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        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_pass http://127.0.0.1:8923/;
    }

问题重现步骤:

使用域名访问公共模板库,点击重建缓存,可在开发者工具中看到 /subscribe/1/updating/ 访问失败,后端日志状态码显示403,开启Debug后,可看到具体的报错为:

tornado.general websocket:267] Cross origin websockets not allowed

解决:

添加 check_origin 函数配合配置项 domain 进行跨域验证以解决该问题

@a76yyyy a76yyyy merged commit dbc3884 into qd-today:master Aug 22, 2023
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants