0

저는 Play Framework 2.5.10에서 빌드 된 REST API 프로덕션을 실행하고 있습니다. 그 NGINX 역방향 라우팅을 통해 실행, 나는 모든 GET 종점에 도달 할 수 있지만 모든 POST 종점에서 시간 제한을받습니다,이 모든 JSON을 소모합니다.Play Framework 타임 아웃을 반환하는 POST 끝점 - 504

개발 환경에서 잘 작동하며 모든이 끝점에 도달 할 수 있지만 프로덕션 환경에서는 IP를 통해 또는 역방향 경로 DNS를 통해 연결하여 POST에 시간 초과가 발생합니다.

이 문제를 해결하기위한 모든 조언을 매우 적극 환영합니다.

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; 
    } 
} 

경로

POST /auth      controllers.Application.authenticate() 

내가 Nginx에 모든 경로를 정의해야합니까 액세스하려고?

추가 된 인증 코드의 경우 귀하의 POST 요청 몸이 크고 연결이 느린 및/또는 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

그 nginx를 기본적으로 않습니다.

로그 파일에서 nginx는 대형 바디가 디스크에 캐시 될 때도 경고해야합니다. 이 경우에 백업 서버로 장애 조치를 배제 것

proxy_request_buffering off; 

참고 : 그 문제가있는 경우

, 당신은 http, serverlocation 스탠자 안에 유효 다음 지시문과 버퍼링 요청을 해제 할 수 있습니다 해당 기능을 사용하고있는 경우에 대비하여 그렇지 않다면 괜찮습니다. 당신이 원하는 경우

은 특정 location의 또는 단지 POST 방법에 대한 예를 들어, 당신은 선택적으로 요청 버퍼링을 해제 할 수 있습니다, 또한 http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering

참조하십시오.

+0

굉장한 올바른 방향으로 나를 가리켰다. – Seroney

관련 문제