nginx配置文件如下:
server {
listen 443 ssl;
server_name www.domain.com;
root /www/web;
index index.html index.php; ssl_certificate cert/2268832_www.domain.com.pem;
ssl_certificate_key cert/2268832_www.domain.com.key; ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_prefer_server_ciphers on; location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
} if ( $host != 'www.domain.com' ) {
rewrite "^/(.*)$" https://www.domain.com/$1 permanent;
} location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
} location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
} #location / {
# root html;
# index index.html index.htm;
#}
} server {
listen 80;
server_name www.domain.com;
rewrite ^(.*)$ https://$host$1 permanent; }
检测配置是否正确命令:
/usr/local/nginx/nginx -t
配置正确重启nginx:
/usr/local/nginx/nginx -s reload
最后就可以访问网站看到https了。