7
我想配置nginx代理将请求传递给另一个服务器,只要$ request_body变量匹配特定的正则表达式。但它不适用于我。基于请求正文内容的nginx条件代理传递
server{
listen 80 default;
server_name www.applozic.com;
location/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
if ($request_body ~* (.*)appId(.*)) {
proxy_pass http://apps.applozic.com;
}
}
}
请求正文::
{
"applicationId": "appId",
"authenticationTypeId": 1,
"enableEncryption": false,
"notificationMode": 0,
"deviceType": 4,
}
[在位置nginx的匹配特定词]的可能的复制(https://stackoverflow.com/questions/7888165/nginx-match-specific-word-in-location) – AlexD