2

非常に具体的なnginx構成の質問があります:

私はnginxが必要です:

  • プロキシWebSocket接続@/
  • 標準のhttpリクエストに対してindex.htmlで応答する@/

これは私が得ることができる最も近いものです:

  location = / {
   if ($http_upgrade != "websocket") {
    # Here lies my problem:
    # This returns a http: 302 where i just need it to return the contents
    # of index.html
    return https://admin.permaconn.com/index.html;
   }

   proxy_http_version 1.1;
   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection "upgrade";
   proxy_pass http://localhost:8080;
  }

アプリで、nodejsをフロントプロキシとして使用することから、nginxをフロントエンドプロキシとして使用することへの構造変更が行われています。

すでにデバイス(別名レガシー)がインストールされている多数のプログラムから予想される動作のため、nginxをこのように構成する必要があります。

4

1 に答える 1

11

returnディレクティブを誤用しています。

location = / {
    index index.html;

    if ($http_upgrade = "websocket") {
        proxy_pass http://localhost:8080;  
    }

    proxy_http_version 1.1;
    proxy_set_header Upgrade websocket;
    proxy_set_header Connection upgrade;
}

ドキュメント:

于 2013-03-06T14:43:49.843 に答える