support http and https on the same port

Maxim Dounin mdounin at
Wed Jul 25 20:23:03 UTC 2018


On Wed, Jul 25, 2018 at 11:37:20AM -0700, Frank Liu wrote:

> I tried:
> error_page 497 $request_uri;
> It is kind of working, and I get the correct content/code back, but the
> response header is still has 400:
> HTTP/1.1 400 Bad Request
> My use case has nginx as a reverse proxy, and the real response code from
> upstream is dropped though the response body and other headers are retained.
> I also tried:
> error_page 497 =200 $request_uri;
> and now I get:
> HTTP/1.1 200 OK
> instead of real response code from upstream.

Try this instead:

    error_page 497 = @http;

    location @http {
        proxy_pass http://upstream.server;

But, as previously said, it might not be a good idea to actually 
configure things that way.  Rather, 497 can and should be used to 
return a proper error and/or redirection to the correct address 
with the protocol properly specified.

Maxim Dounin

More information about the nginx mailing list