当前位置首页 > Nginx知识

nginx配置websocket

阅读次数:266 次  来源:admin  发布时间:
# 配置在server同级
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''   close;
}
server {
  listen                          80;
  server_name                     localhost;
  client_max_body_size            512M;
  keepalive_timeout               1800s;
  sendfile                        on;
  chunked_transfer_encoding       on;
  root                            /app/face_safe/dist;
  index                           index.html;

  location / {
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods *;
    add_header Access-Control-Allow-Headers *;
    try_files                     $uri $uri/ @req;
    index                         index.html;
  }

  location @req {
    rewrite ^.*$                  /index.html last;
  }

  location /v1 {
    proxy_set_header Access-Control-Allow-Origin *;
    proxy_set_header Access-Control-Allow-Methods *;
    proxy_set_header Access-Control-Allow-Headers *;
    proxy_set_header Upgrade $http_upgrade;  # websocket
    proxy_set_header Connection $connection_upgrade;  # websocket 
    proxy_pass                    http://172.17.0.1:8000;
  }
}
上一篇:debianopencl环境搭建
下一篇:Centos7用yum命令安装LAMP环境(php+Apache+Mysql)以及php扩展