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;
}
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:
Then add
default_server
to your site vhost definition:Reload:
nginx -s reload
Test with curl:
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.