2

I have a web server running nginx. If I access the website through a wifi connection, it loads the website. If I access it using LTE on my phone, it just shows the default "Welcome to nginx!" page

Here is my site config file:

server {
    listen 80;
    listen 443 ssl;
    server_name {mysite.com};

    root   /path/to/public;
    index  index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
        include   /etc/nginx/conf.d/php-fpm;
    }

    ssl_certificate /etc/letsencrypt/live/{mysite.com}/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/{mysite.com}/privkey.pem;
}
3
  • The {mysite.com} is mysite.com in your real file right? – MGP Nov 30 '16 at 23:49
  • @ManuelGutierrez yes just wanted to keep the name private – andrewtweber Dec 1 '16 at 0:00
  • Run a few tests using webpagetest.org from different locations or the google pagespeed service. If they work the problem is your phone or service provider. Post the actual URL if you want useful advice. – Tim Dec 1 '16 at 0:17
2

That "Welcome" makes me suspect nginx is not reading the Host header in the request and the response is the default virtual host definition (which is the welcome message).

Remove your default vhost, on debian should be:

rm /etc/nginx/sites-enabled/default

Then add default_server to your site vhost definition:

listen 80 default_server;
listen 443 ssl default_server;

Reload: nginx -s reload

Test with curl:

curl -H "Host: mysite.com" mysite.com
curl mysite.com

The first request is sending the host header, the second does not. Both should return the same becase mysite.com is default now for ports 80 and 443 (one default_server for port).

This is like a brute force method, a smarter way would be debugging the requests, if all is correctly set up this should not happen.

1
  • You are right, it was the default. I think it is this line specifically inside the default: listen [::]:80 default_server ipv6only=on;. So it looks like on LTE it was connecting using ipv6 but on Wifi using ipv4? – andrewtweber Dec 1 '16 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.