2022年4月28日
nginx配置ssl以及http重定向https
编辑服务器/etc/nginx/nginx.conf添加以下代码,进行相应自己相关域名、证书修改
server {
listen 443 ssl;
server_name www.xxx.com;
root /var/www/xxx;
index index.html index.htm index.php;
ssl_certificate /xxx.pem;
ssl_certificate_key /xxx.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM- SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/zhang-access.log;
error_log /var/log/nginx/zhang-error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}
server {
listen 80;
server_name xxx.com;
return 301 https://www.xxx.com$request_uri;
}