nginx代理swoole服务器


伪静态:

#允许跨域,可选项,nginx设置过以后注意swoole响应头中不需要再设置

add_header 'Access-Control-Allow-Origin' '*';

add_header 'Access-Control-Allow-Credentials' 'true';

add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';



location / {

      #不记录options请求

      if ($request_method = 'OPTIONS') {

          access_log off;

        return 204;

      }

      

      proxy_pass http://127.0.0.1:19508; #改为你的swoole服务器地址

       # 将客户端的 Host 和 IP 信息一并转发到对应节点

      proxy_set_header Host $http_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-Proto $scheme;

}


#屏蔽/favicon.ico

location = /favicon.ico {

      return 404;

      expires 300d;

      log_not_found off;

      access_log off;

}


鼎云博客




鼎云博客
  • 最新评论
  • 总共0条评论