Jump to content

NGINX configuration revisited


gebeer
 Share

Recommended Posts

Hello all,

there are some older posts about nginx configuration for PW like 

 

@LostKobrakai created a gist.

We have some sites in production on apache with nginx reverse proxy. One of those is receiving webhooks from snipcart. And in some situations the POST requests from snipcart are redirected through nginx and the POST request body data gets lost in this process. We are receiving those requests in apache with headers like where "HTTP_X_HTTP_METHOD_OVERRIDE": "POST" is sent like this by snipcart

...
  "REQUEST_METHOD": "GET",
  "HTTP_X_HTTP_METHOD_OVERRIDE": "POST",
  "QUERY_STRING": "it=/webhooks/snipcart/&",
...

file_get_contents('php://input'); is null in those cases.


After doing some research I found it could be related to the 

location / {
    try_files $uri $uri/ /index.php?it=$uri&$args;
 }

directive in the nginx vhost.conf.

I couldn't find the reason for the nginx redirect since the POST request is going to an existing endpoint /webhooks/snipcart/ (with trailing slash) and making test requests with POSTMAN didn't result in redirects.

Has anyone else experienced this behaviour and knows a solution?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...