Welcome! Log In Create A New Profile

Advanced

Re: server_name for localhost actually matches <anything>.localhost

oscaretu
December 17, 2018 09:32AM
Hello, Gianluigi

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"

Kind regards,
Oscar

On Mon, Dec 17, 2018 at 8:44 AM Gianluigi Zanettini <info@zane.it> wrote:

>
> Ok, this seems related to the specific use of localhost. If I try it with
> any other domain name, it works as expected.
>
> I'm still interested in an answer for my own learning, but it's definitely
> lower priority now.
>
>
> Il giorno lun 17 dic 2018 alle ore 01:10 Gianluigi Zanettini <info@zane.it>
> ha scritto:
>
>> Hi guys,
>> 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:
>>
>> server {
>>
>> listen 443 ssl default_server;
>> ...
>> return 400;
>> }
>>
>> Then I setup my real config:
>>
>>
>> server {
>>
>> server_name localhost;
>> root /usr/share/nginx/html;
>> listen 443 ssl http2;
>> listen [::]:443 ssl http2;
>> ...
>> }
>>
>>
>>
>> My /etc/hosts:
>>
>> 127.0.0.1 localhost test.localhost bogus.com
>>
>>
>> It works almost as expected: if I open https://127.0.0.1 or
>> https://bogus.com I get my error page, as I expected, and if I open
>> https://localhost I see my site.
>>
>> *The problem is*: if I open https://test.localhost , I also see my
>> website! What? why? my server isn't defined for this hostname!
>>
>> What am I doing wrong?
>>
>> Thanks!
>>
>> O----------------------------------------------------O
>> | Dr. Gianluigi Zanettini info@zane.it |
>> | Tel: +39 338 8562977 Fax: +39 0532 9631162 |
>> | http://TurboLab.it http://zane.it |
>> O----------------------------------------------------O
>>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



--
Oscar Fernandez Sierra
oscaretu@gmail.com
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Fwd: server_name for localhost actually matches <anything>.localhost

ZaneCEO December 16, 2018 07:12PM

Re: server_name for localhost actually matches <anything>.localhost

ZaneCEO December 17, 2018 02:44AM

Re: server_name for localhost actually matches <anything>.localhost

oscaretu December 17, 2018 09:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 299
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready