V
V
Vladimir Yakimov2013-12-12 04:42:20
linux
Vladimir Yakimov, 2013-12-12 04:42:20

How to send a POST request to static files in Nginx?

Task.
Proxy a request based on the value of a POST variable using Nginx.
The load on the server is minimal, so I want to get by with one Nginx.
Description
A request with data in POST url=x1.server.ru arrives at the server.ru server, you need to proxy it to x1.server.ru. If the post has url=x2.server.ru, then we proxy it to x2.server.ru.
Non-working solution

location /
{
    if ($request_body ~* "x1.server.ru") {
       proxy_pass http://x1.server.ru;
       break;
   }
}

We get a 405 Not Allowed error . Nginx does not allow POST requests to static files.
On the Internet I found solutions like: allow_static_post on; but unfortunately they don't work.
ps
Linux server.ru 3.8.0-19-generic #30-Ubuntu SMP Wed May 1 16:35:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
nginx version: nginx/1.2.6 (Ubuntu)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Vasilchuk, 2013-12-12
@Anonym

Send the correct Allow headers to x1.server.ru .

I
iStyx, 2013-12-15
@iStyx

error_page 405 = $uri;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question