【发布时间】:2021-08-16 01:32:53
【问题描述】:
这个配置正确吗?我可以通过 http 访问,但不能通过 https 访问
我在 GCP 计算引擎上的 Ubuntu 20 上安装了 nginx。下面是 nginx 配置文件
server {
listen 80;
server_name testprojects.com www.testprojects.com;
return 301 http://$server_name$request_uri;
}
server {
listen default_server 443 ssl;
server_name testprojects.com www.testprojects.com;
ssl_certificate /home/testprojects_com.crt;
ssl_certificate_key /home/testprojects_com.key;
access_log /var/log/nginx/nginx.index.access.log;
error_log /var/log/nginx/nginx.index.error.log;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location = /test {
return test.html;
}
}
【问题讨论】: