如果我使用https访问我的nginx网站,它正在工作,但用http下载一个名为“download”的文件(没有任何扩展名),57字节并用记事本等打开它只显示乱码的东西。
这是我的虚拟主机configuration:
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 ▒▒
我发现是什么导致了这个问题:我正在使用listen 80 http2; 在我的虚拟主机configuration,显然不工作 。 当我从上述行中删除http2后,它现在正常工作了!