C
C
cyberorg2013-10-23 13:13:00
Nginx
cyberorg, 2013-10-23 13:13:00

Nginx, trailing slash and POST requests?

Good afternoon, Habralyudi!
There was a question related to the nginx configuration:
Now the config looks like this:

server {
    listen 80;
    server_name erk.dev;
    
    location / {
        root /opt/web/nginx/sites/erk.dev/code;
        access_log /opt/web/nginx/sites/erk.dev/logs/access.log;
        error_log /opt/web/nginx/sites/erk.dev/logs/error.log;
    }

    location /app {
       proxy_pass http://127.0.0.1:9090/kyber;
       access_log /opt/web/nginx/logs/upstreams/erk.access.log upstreamlog;
       error_log /opt/web/nginx/logs/upstreams/erk.error.log;
    }
}

If I make a POST request to erk.dev/app/ it works fine.
However, there is a request to send to http//:erk.dev/app, then the POST request comes to Nginx, it responds with 302
and the next request goes to erk.dev/app/ , but this is a GET request.
How to correctly configure Nginx so that, regardless of whether there is a slash at the end or not, nginx sends a POST request to upstream?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maximus43, 2013-10-23
@kyberorg

Most likely (99%) the redirect comes from the backend.
Try like this

location /app {
 if ($request_method !~ ^(POST)$ ) {
         return 444;
     }
                proxy_pass      proxy_pass http://127.0.0.1:9090/kyber/app/$is_args$args;
                access_log /opt/web/nginx/logs/upstreams/erk.access.log upstreamlog;
       error_log /opt/web/nginx/logs/upstreams/erk.error.log;
}

N
Nikolai Vasilchuk, 2013-10-23
@Anonym

There is a suspicion that the redirect is not done by Nginx.

K
kyberorg, 2013-10-23
@kyberorg

Judging by the response and the headers, after all, Nginx.
It could be this situation:
en.wikipedia.org/wiki/Post/Redirect/Get ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question