0

私はPlay Framework 2.5.10で構築されたREST APIプロダクションを実行しています。 NGINXのリバースルーティングを実行すると、すべてのGETエンドポイントに到達できますが、すべてのPOSTエンドポイントでタイムアウトが発生します。これはすべてJSONを消費します。Play Frameworkタイムアウトを返すPOSTエンドポイント - 504

開発環境でうまく動作し、このエンドポイントにはすべて到達できますが、本番環境では、IP経由または逆ルートDNS経由で接続するかどうかにかかわらずPOSTでタイムアウトになります。

これを解決するためのあらゆる指針が高く評価されています。

POST /auth      controllers.Application.authenticate() 

にアクセスしようとしている

server { 
listen 80; 
server_name subdomain.domain.com; 

location/{ 
    proxy_connect_timeout  300; 
    proxy_send_timeout   300; 
    proxy_read_timeout   300; 
    send_timeout    300; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header Host  $http_host; 
    proxy_http_version 1.1; 
    proxy_set_header Connection ""; 
    proxy_pass http://xxx.xxx.xxx.xxx:3000; 
    } 
} 

ルート私はnginxの上のすべてのルートを定義する必要がありますか?

追加の認証コード

@BodyParser.Of(BodyParser.Json.class) 
public Result authenticate(){ 
    JsonNode json = request().body().asJson(); 
    EncryptUtil secure = null; 
    secure=EncryptUtil.getSecurityUtility(); 
    String command = "login"; 
    String logincommand = json.findPath("command").asText(); 
    if (logincommand.equals(command)){ 
     String email = json.findPath("email").textValue(); 
     String password = json.findPath("password").textValue(); 
     Logger.info("Passwords::"+password+"\t"+secure.getEncryptedUserPassword(password.trim())); 
     UserAccount user=UserAccount.findByEmail(email); 
     if(user!=null){ 
      if(!(secure.getDecryptedUserPassword(user.password).equals(password))){ 
       return status(400,"Invalid credentials"); 
      }else { 
       if (user.accountstatus == Boolean.FALSE){ 
        result.put("error","Account Deactivated Contact Admin"); 
        return status(400,"Account Deactivated Contact Admin"); 

       } else { 
        String authToken = user.createToken(); 
        ObjectNode authTokenJson = Json.newObject(); 
        authTokenJson.put(AUTH_TOKEN, authToken); 
        response().setCookie(Http.Cookie.builder(AUTH_TOKEN, authToken).withSecure(ctx().request().secure()).build()); 
        JsonNode userJson = Json.toJson(user); 
        return status(200,userJson); 
       } 

      } 

     } 
     else{ 
      result.put("Error", "Invalid User"); 
      Logger.info(result.toString()); 
      return status(400,"Invalid Credentials"); 
     } 
    } else{ 
     return globalFunctions.returnBadRequest(command); 
    } 

} 
+0

(あなたのコントローラ内の)POSTアクションとnginx confの関連セクションの方法を共有してください。 – marcospereira

+0

@marcospereiraあなたがリクエストした情報を投稿しました。 – Seroney

+0

POST要求が実際にアプリケーションに到着していることを確認できますか? 'authenticate'メソッドのコードも投稿できますか? – marcospereira

答えて

1

あなたのPOSTリクエスト体が大きく、接続が遅いおよび/またはnginxの一時ファイルを格納する媒体はnginxのこと、これは要求のバッファリングによって引き起こされることが、遅い場合にはデフォルトでは行います。

nginxはログファイルで、大規模な本体がディスクにキャッシュされていることを警告する必要があります。

それがあなたの問題である場合は、httpserverlocationスタンザ内の有効な次のディレクティブでバッファリング要求を無効にすることができます。これは、いくつかのケースでは、バックアップサーバへのフェイルオーバーを排除することを

proxy_request_buffering off; 

注意をその機能を使用している場合に備えてそうでなければ、あなたは大丈夫です。

も参照してくださいhttp://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering

あなたがしたい場合は、インスタンスのための唯一の特定のlocation秒間またはちょうどPOST方法のために、選択的要求のバッファリングを無効にすることができます。

+0

素晴らしい方向に私を指摘 – Seroney

関連する問題