我已经将网站从运行apache的物理服务器迁移到了运行nginx的虚拟机。
当我进入网站直接链接时,网站启动:http://www.via-ap.com
但是当我访问Google时,如果单击右侧面板上的网站,则会收到404错误。
请参见下文:
我从许多浏览器和专用模式进行了这些测试。
我的默认nginx vhost conf是:
server {
server_name _;
listen 80 default_server;
listen 443 ssl default_server;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
return 404;
}
,然后每个网站都有自己的conf,如下所示:
server {
listen 80;
listen [::]:80;
server_name website.com;
return 301 https://www.$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.website.com website.com;
root /home/website/www/;
index index.html index.htm index.php;
access_log /var/log/nginx/website.access_log;
error_log /var/log/nginx/website.error_log info;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm-website.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
include /etc/nginx/conf/website.conf; /* file where strict transport security headers are defined */
ssl_certificate /etc/letsencrypt/live/website.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/website.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/website.com/chain.pem;
include /etc/nginx/conf/ssl.conf;
}
你知道为什么吗?
谢谢
答案 0 :(得分:0)
解决方案。 在第一个服务器块上(侦听80)
正如您首先说的,除了 website.com
然后我将 return 301 https://www。$ host $ request_uri; 替换为 return 301 https:// $ host $ request_uri; < / p>