支持强制跳转HTTPS
server {
listen 80;
server_name www.test.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}
server {
listen 443;
server_name www.test.com;
ssl on;
ssl_certificate cert/xxxxxxxxx.pem;
ssl_certificate_key cert/xxxxxxxx.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;
ssl_prefer_server_ciphers on;
index index.php index.htm index.html;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location ~ \.php {
root /alidata/www/html;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
HTTP和HTTPS都可以访问
server {
listen 80;
listen 443 ssl;
server_name www.test.cn;
# ssl on; 未开启 开启会报错
ssl_certificate cert/xxxxxxxxx.pem;
ssl_certificate_key cert/xxxxxxxx.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;
ssl_prefer_server_ciphers on;
...
配置文件参数 说明
listen 443 SSL访问端口号为443
ssl on 启用SSL功能
ssl_certificate 证书文件
ssl_certificate_key 私钥文件
ssl_protocols 使用的协议
ssl_ciphers 配置加密套件,写法遵循openssl标准
```