Question

I have nginx proxying to an app server, with the following configuration:

location /app/ {
        # send to app server without the /app qualifier
        rewrite /app/(.*)$ /$1 break;
        proxy_set_header Host $http_host;
        proxy_pass http://localhost:9001;
        proxy_redirect http://localhost:9001 http://localhost:9000;
    }

Any request for /app goes to :9001, whereas the default site is hosted on :9000.

GET requests work fine. But whenever I submit a POST request to /app/any/post/url it results in a 404 error. Hitting the url directly in the browser via GET /app/any/post/url hits the app server as expected.

I found online other people with similar problems and added

proxy_set_header Host $http_host; but this hasn't resolved my issue.

Any insights are appreciated.

Thanks.

Était-ce utile?

La solution

My bad, the problem wasn't nginx, it was my app server. I was using a routing module that required me to explicitly specify the request method if not a get, and so that's why it was throwing a 404 error on post, but not when hitting the browser url directly.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top