Skip to content

部署SuWS服务

Nginx配置

SuWS 服务默认监听 8788 端口,您可以通过配置 config.json 修改监听端口。

nginx
location ^~ /
{
  proxy_pass http://127.0.0.1:8788;
  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_set_header REMOTE-HOST $remote_addr;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
  proxy_http_version 1.1;
  proxy_read_timeout 300;
  add_header X-Cache $upstream_cache_status;
  #Set Nginx Cache
  set $static_fileuPhsZAmz 0;
  if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
  {
    set $static_fileuPhsZAmz 1;
    expires 1m;
  }
  if ( $static_fileuPhsZAmz = 0 )
  {
    add_header Cache-Control no-cache;
  }
}
location /websocket
{
  proxy_pass http://127.0.0.1:8788;
  proxy_http_version 1.1;
  proxy_read_timeout 300;
  proxy_set_header Host $host;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
  proxy_set_header X-Real-IP $remote_addr;
}
nginx
location /{
  try_files $uri $uri/index.html @suws;
}
location @suws
{
  proxy_pass http://127.0.0.1:8788;
  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_set_header REMOTE-HOST $remote_addr;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
  proxy_http_version 1.1;
  proxy_read_timeout 300;
}
location /websocket
{
  proxy_pass http://127.0.0.1:8788;
  proxy_http_version 1.1;
  proxy_read_timeout 300;
  proxy_set_header Host $host;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
  proxy_set_header X-Real-IP $remote_addr;
}