i am trying to configure nginx to proxy pass the request to another server, only if the $request_body variable matches on a specific regular expression.
My problem now is, that I don't how to configure this behaviour exactly.
I am currently down to this one:
server {
listen 80 default;
server_name test.local;
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 ~* ^(.*)\.test) {
proxy_pass http://www.google.de;
}
root /srv/http;
}
}
but the problem here is, that root has always the upperhand. the proxy won't be passed either way.
any idea on how I could accomplish this?
thanks in advance
$request_bodyagainst regexp? It will slow your app for x times Also, do you want to doproxy_passor justredirect?