<div dir="ltr"><div>I tried:</div><div><br></div><div>error_page 497 $request_uri;</div><div><br></div><div>It is kind of working, and I get the correct content/code back, but the response header is still has 400:</div><div><br></div><div>HTTP/1.1 400 Bad Request</div><div><br></div><div>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.</div><div><br></div><div>I also tried:</div><div>error_page 497 =200 $request_uri;</div><div>and now I get:</div><div>HTTP/1.1 200 OK</div><div>instead of real response code from upstream.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 25, 2018 at 10:26 AM, Frank Liu <span dir="ltr"><<a href="mailto:gfrankliu@gmail.com" target="_blank">gfrankliu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I just tried it quickly. nginx gives 400 instead of 497 when I connect as http to a ssl virtual host.</div><div><br></div><div>server {<br>  listen       8443 ssl;<br>  server_name  localhost;<br><br>  ssl_certificate      /opt/nginx/ssl/localhost.crt;<br>  ssl_certificate_key  /opt/nginx/ssl/localhost.key;<br><br>  ssl_session_cache    shared:SSL:10m;<br>  ssl_session_timeout  10m;<br><br>}<br></div><div><br></div><div>curl -v <a href="http://localhost:8443" target="_blank">http://localhost:8443</a><br>* About to connect() to localhost port 8443 (#0)<br>*   Trying 127.0.0.1...<br>* Connected to localhost (127.0.0.1) port 8443 (#0)<br>> GET / HTTP/1.1<br>> User-Agent: curl/7.29.0<br>> Host: localhost:8443<br>> Accept: */*<br>> <br>< HTTP/1.1 400 Bad Request<br>< Server: nginx/1.15.2<br>< Date: Wed, 25 Jul 2018 17:23:24 GMT<br>< Content-Type: text/html<br>< Content-Length: 271<br>< Connection: close<br>< <br><html><br><head><title>400 The plain HTTP request was sent to HTTPS port</title></head><br><body bgcolor="white"><br><center><h1>400 Bad Request</h1></center><br><center>The plain HTTP request was sent to HTTPS port</center><br><hr><center>nginx/1.15.2</<wbr>center><br></body><br></html><br>* Closing connection 0</div><div><br></div><div>Am I missing something?</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 25, 2018 at 9:16 AM, Frank Liu <span dir="ltr"><<a href="mailto:gfrankliu@gmail.com" target="_blank">gfrankliu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks Maxim!</div><div>Is there a way to tell nginx to treat 497 as no error, and continue normal processing?<br></div></div><div class="m_2872315389866341587HOEnZb"><div class="m_2872315389866341587h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 25, 2018 at 8:14 AM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<span><br>
On Wed, Jul 25, 2018 at 07:46:49AM -0700, Frank Liu wrote:<br>
<br>
> Stream servers can now do ssl and non-ssl on the same port:<br>
> <a href="https://www.nginx.com/blog/running-non-ssl-protocols-over-ssl-port-nginx-1-15-2/" rel="noreferrer" target="_blank">https://www.nginx.com/blog/run<wbr>ning-non-ssl-protocols-over-ss<wbr>l-port-nginx-1-15-2/</a><br>
> <br>
> Can this be added to http virtual hosts as well?<br>
> If ssl is on a listening port and client doesn't send ClientHello, can<br>
> nginx fallback to use normal http? Maybe introduce a new directive<br>
> "fallback_http on;"?<br>
<br>
</span>It is available since nginx 0.1.0, see the 497 error code here:<br>
<br>
<a href="http://nginx.org/en/docs/http/ngx_http_ssl_module.html#errors" rel="noreferrer" target="_blank">http://nginx.org/en/docs/http/<wbr>ngx_http_ssl_module.html#error<wbr>s</a><br>
<br>
It might not be a good idea to actually configure things that way <br>
though.<br>
<span class="m_2872315389866341587m_-481456999682148012HOEnZb"><font color="#888888"><br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailm<wbr>an/listinfo/nginx</a><br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>