# 监听80端口,http请求转发到https监听的443端口
server {
listen 80;
server_name localhost;
return 301 https://$server_name$request_uri;
}
# 监听443端口,https请求
server {
listen 443 ssl;
root /var/www/html;
index index.php index.html index.htm;
server_name localhost;
ssl on;
ssl_certificate /etc/nginx/ssl/cert.crt; # 证书路径
ssl_certificate_key /etc/nginx/ssl/cert.key; # 证书路径
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
# 其他配置
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
}