Nginx serving wrong site

James Read jamesread5737 at gmail.com
Mon Jan 8 16:48:13 UTC 2024


On Mon, 8 Jan 2024, 11:34 James Read, <jamesread5737 at gmail.com> wrote:

>
>
> On Mon, 8 Jan 2024, 10:04 Francis Daly, <francis at daoine.org> wrote:
>
>> On Mon, Jan 08, 2024 at 09:49:23AM -0500, James Read wrote:
>> > On Mon, 8 Jan 2024, 09:29 Francis Daly, <francis at daoine.org> wrote:
>> > > On Mon, Jan 08, 2024 at 09:13:38AM -0500, James Read wrote:
>>
>> Hi there,
>>
>> > > So I'm going to guess that your "server_name" line is of the
>> > > form "www.example.com"; and your browser is instead accessing
>> > > http://example.com; and nginx is returning the content of the
>> > > default_server for that ip:port instead of this server.
>> >
>> > My server_name is of the form "example.com www.example.com;" so I don't
>> > think that is the problem. Could this be anything to do with dns
>> > configuration?
>>
>> Do your nginx logs indicate that the request is being handled by this
>> nginx instance at all?
>>
>> If not, maybe DNS is not causing your browser to talk to this server's
>> IP address.
>>
>> The logs look fine. They are showing the requests.
>>
>>
>> Do you have any "listen" directives that include specific IP addresses,
>> instead of just ports? Does your example.com resolve to the address
>> of the "listen" in this "server{}"; or to the address of the "listen"
>> in whichever "server{}" is actually being used; or to a different address?
>>
>
> server {
>         listen 80;
>         listen [::]:80;
>
>         root /var/www/moshiim.it;
>
>         index index.php index.html index.htm index.nginx-debian.html;
>         server_name example.com www.example.com;
>         location / {
>
>                 try_files $uri $uri/ =404;
>         }
>
>        location ~ \.php$ {
>                 include snippets/fastcgi-php.conf;
>                 fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
>         }
>
> }
>

OK this is a browser issue and not a nginx issue. I just accessed the site
with lynx and it is showing the right site. However with Chrome it is
showing the wrong site. This may have something to do with the fact that I
had to clear the HSTS cache in the browser in order to be able to see
anything. The domain used to have a SSL certificate and Chrome was refusing
display because it detected the site had no SSL certificate. I need to
figure out how to get Chrome to behave normally.


>
>> Cheers,
>>
>>         f
>> --
>> Francis Daly        francis at daoine.org
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> https://mailman.nginx.org/mailman/listinfo/nginx
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20240108/2069dd15/attachment.htm>


More information about the nginx mailing list