Expect: 100-continue with the nginx proxy_pass

Maxim Dounin mdounin at mdounin.ru
Wed Apr 24 13:07:48 UTC 2019


On Wed, Apr 24, 2019 at 03:14:08AM -0400, simanto604 wrote:

> We are integrating a 3rd party payment gateway which on a successful
> transaction sends a [IPN][1] request. So we have built a API endpoint to
> handle the request which works fine in dev env. 
> Now the issue is when we use nginx infront of the API Server it gets 301
> redirects. When we are using a proxy tunnel like [ngrok][2], which proxies
> the http request via ngrok servers, the request passes through nginx to our
> API server successfully but when the IPN POST request is directly served to
> our nginx it gets a 301 redirect. To dig deeper we intercept the request
> with a python [SimpleHttpServer][3] leading us to find the difference of
> http headers:
>  - without ngrok (direct to nginx)
> > ['Host:\r\n', 'Accept: */*\r\n', 'Content-Length:
> > 1030\r\n', 'Content-Type: application/x-www-form-urlencoded\r\n',
> > '**Expect: 100-continue**\r\n']
>  - With ngrok
> > ['Host: 543fdf1c.ngrok.io\r\n', 'Accept: */*\r\n', 'Content-Length:
> > 1013\r\n', 'Content-Type: application/x-www-form-urlencoded\r\n',
> > 'X-Forwarded-For: 2a01:4f8:192:22ec::2\r\n']
> We are assuming the issue lies with the `Expect: 100-continue` headers. So
> the question is there any way to handle this with Nginx? or what is the
> industry standard solution for such scenerio?

Most likely, the reason is not "Expect: 100-continue", but the 
Host header, which is also different.

> FYI: Nginx conf: 
>     location /api/ {
>     proxy_set_header Expect $http_expect;

Note that this is simply wrong and likely to break things 
completely as long as there is Expect header in the request.


Maxim Dounin

More information about the nginx mailing list