我正在运行基于 Play Framework 2.5.10 构建的 REST API 产品。它通过 NGINX 反向路由运行,我能够到达所有 GET 端点,但我在所有 POST 端点上都超时,所有这些都消耗 JSON。
请注意,在开发环境中它工作正常,我能够到达所有这些端点,但在生产中,无论是通过 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 上定义所有路由吗?
添加了授权码
@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);
}
}