如果我使用 https 访问我的 nginx 站点,它可以正常工作,但使用 http 时,它会下载一个名为“download”的文件(没有任何扩展名),57 个字节,使用记事本等打开它只会显示乱码。
这是我的虚拟主机配置:
server {
server_name www.domain.com domain.com;
listen 80;
return 301 https://domain.com$request_uri;
}
server {
server_name www.domain.com
listen 443 ssl;
/* SSL Stuff */
return 301 https://domain.com$request_uri;
}
server {
server_name domain.com;
index index.php index.html index.htm;
listen 443 ssl;
root /usr/share/nginx/domain.com;
/* SSL Stuff */
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\. {
deny all;
}
}
curl-v:
curl -v http:/domain.com *
Rebuilt URL to: http://domain.com/ *
Hostname was NOT found in DNS cache *
Trying 175.*.*.*... *
Connected to domain.com (175.*:*:*) port 80 (#0)
> GET / HTTP/1.1 > User-Agent: curl/7.38.0
> Host: domain.com > Accept: */*
> * Connection #0 to host domain.com left intact
▒▒
答案1
我发现了问题的原因:我listen 80 http2;
在我的 vhost 配置中使用了不起作用。从上述行中删除 http2 后,它现在又可以正常工作了!