<div dir="ltr"><div>Hello, Gianluigi</div><div><br></div><div>I suppose the response is coming from the default server: if the vhost servername of the request doesn't match any of the defined ones, the answer will come from the default server. If you add an alternate servername "test.localhost" where you defined "localhost" in the config file, you should see the same content that you see when you use "localhost"</div><div><br></div><div>Kind regards,</div><div>Oscar<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 17, 2018 at 8:44 AM Gianluigi Zanettini <<a href="mailto:info@zane.it">info@zane.it</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br clear="all"><div><div dir="ltr" class="gmail-m_7445868489331566306gmail_signature"><div dir="ltr"><div><div><font face="monospace, monospace">Ok, this seems related to the specific use of localhost. If I try it with any other domain name, it works as expected.</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">I'm still interested in an answer for my own learning, but it's definitely lower priority now.</font></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr">Il giorno lun 17 dic 2018 alle ore 01:10 Gianluigi Zanettini <<a href="mailto:info@zane.it" target="_blank">info@zane.it</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi guys,</div><div>I'm testing my config on localhost with nginx/1.15.7 before deploying. Since I only want to handle specific hostnames, I setup a catch-default:</div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px"><div><div><div><div><font face="monospace, monospace">server {</font></div></div></div></div><div><div><div><div><font face="monospace, monospace"><br></font></div></div></div></div><div><div><div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>listen 443 ssl default_server;</font></div></div></div></div><div><div><div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>...</font></div></div></div></div><div><div><div><div><span style="white-space:pre-wrap"><font face="monospace, monospace"> </font></span></div></div></div></div><div><div><div><div><font face="monospace, monospace"> return 400;</font></div></div></div></div><div><div><div><div><font face="monospace, monospace">}</font></div></div></div></div><div><font face="monospace, monospace"><br></font></div></blockquote><font face="arial, helvetica, sans-serif">Then I setup my real config:</font></div></div></div><blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px"><div><div><div><font face="monospace, monospace"><br></font></div></div></div><div><div><div><div><font face="monospace, monospace">server {</font></div></div></div></div><div><div><div><div><font face="monospace, monospace"><br></font></div></div></div></div><div><div><div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>server_name localhost;</font></div></div></div></div><div><div><div><div><font face="monospace, monospace"><span style="white-space:pre-wrap"> </span>root /usr/share/nginx/html;</font></div></div></div></div><div><div><div><div><div><font face="monospace, monospace">listen 443 ssl http2;</font></div></div></div></div></div><div><div><div><div><div><font face="monospace, monospace">listen [::]:443 ssl http2;</font></div></div></div></div></div><div><div><div><div><div><font face="monospace, monospace">...</font></div></div></div></div></div><div><div><div><div><div><font face="monospace, monospace">}</font></div></div></div></div></div></blockquote><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div><br></div><div>My /etc/hosts:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px"><div><font face="monospace, monospace">127.0.0.1 localhost test.localhost <a href="http://bogus.com" target="_blank">bogus.com</a></font></div></blockquote><div><br></div><div>It works almost as expected: if I open <a href="https://127.0.0.1" target="_blank">https://127.0.0.1</a> or <a href="https://bogus.com" target="_blank">https://bogus.com</a> I get my error page, as I expected, and if I open <a href="https://localhost" target="_blank">https://localhost</a> I see my site.</div><div><br></div><div><b>The problem is</b>: if I open <a href="https://test.localhost" target="_blank">https://test.localhost</a> , I also see my website! What? why? my server isn't defined for this hostname!</div><div><br></div><div>What am I doing wrong?</div><div><br></div><div>Thanks!</div><br clear="all"><div><div dir="ltr" class="gmail-m_7445868489331566306gmail-m_217985278659703266m_3355238982514336777gmail_signature"><div dir="ltr"><div><div><span style="font-family:monospace,monospace">O----------------------------------------------------O<br>| Dr. Gianluigi Zanettini <a href="mailto:info@zane.it" target="_blank">info@zane.it</a> |<br>| Tel: +39 338 8562977 Fax: +39 0532 9631162 |<br></span></div><span style="font-family:monospace,monospace">| <a href="http://TurboLab.it" target="_blank">http://TurboLab.it</a> <a href="http://zane.it" target="_blank">http://zane.it</a> |<br></span></div><span style="font-family:monospace,monospace">O----------------------------------------------------O<br></span></div></div></div></div></div></div></div></div></div>
</div></div>
</blockquote></div>
_______________________________________________<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/mailman/listinfo/nginx</a></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Oscar Fernandez Sierra<br><a href="mailto:oscaretu@gmail.com" target="_blank">oscaretu@gmail.com</a></div>