配置https域名
1、申请ssl证书
xxx.crt xxx.key
crt
-----BEGIN CERTIFICATE-----
xxx
-----END CERTIFICATE-----
key
-----BEGIN PRIVATE KEY-----
xxx
-----END PRIVATE KEY-----
2、将crt、key文件放入
/usr/local/nginx/conf
目录下。
3、开启443端口
4、配置nginx
server{
#使用443端口
listen 443 ssl;
#listen 80;
server_name a.jq.com;
root /home/wwwroot/default/jq;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
#证书文件
ssl_certificate a.jq.com.crt;
#私钥文件
ssl_certificate_key a.jq.com.key;
ssl_prefer_server_ciphers on;
...
}
server{
listen 443 ssl;
index index.html index.htm index.php;
server_name www.a.com;
root /home/wwwroot/default/a/Public;
include enable-php-pathinfo.conf;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_certificate a.crt;
ssl_certificate_key a.key;
ssl_prefer_server_ciphers on;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/a/access.log;
}
5、重启nginx生效