呼呼胡胡huhu 2020-05-27 17:41 采纳率: 0%
浏览 254

为什么在nginx上部署 Flask-scoket.io+Vue-scoket.io 服务器无法正常运作?

Flask-scoket.io+Vue-scoket.io+nginx+gunicorn部署问题

一直报 400(bad request)错误

vue main.js代码

Vue.use(new VueSocketIO({
  debug: true,
  // 服务器端地址
  connection: '/a/text',

 }))

Vue.config.js代码

 '/a': {
        target: 'http://59.110.69.160:8070',
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/a': ''
        }

nginx.conf部署代码

server {
        listen       8070 default_server;
        listen       [::]:8070 default_server;  
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location /socket.io {/这里 加上 ^~ 重写的化也是400
        proxy_pass http://127.0.0.1:5010;这里尝试着用/scoket.io都没有用
        proxy_redirect off;
        proxy_buffering off;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header Access-Control-Allow-Origin *;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";

    }
    }

gunicorn启动

gunicorn -k gevent -w 5 -b 127.0.0.1:5010 socket:app
  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2020-09-16 12:57
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波