问题原文
原帖链接 · andrewtweber · CC BY-SA 3.0
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;
}
已采纳解答
原帖链接 · MGP · CC BY-SA 3.0
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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
