1.存放不同域名证书目录(加下载好的nginx证书放到对应的目录 )
2. 关联配置文件目录
3.配置文件内容
子域名配置https (需要在阿里云或其他云服务器添加解析),二级域名解析到主ip
server {
listen 80;
server_name api.flxblog.club;
location / {
rewrite (.*) https://api.flxblog.club$1 permanent;
}
}
server {
# SSL configuration
#
listen 443;
ssl on; # 1.1版本后这样写
server_name api.flxblog.club; #填写绑定证书的域名
ssl_certificate /etc/nginx/apiCart/1_api.flxblog.club_bundle.crt;
ssl_certificate_key /etc/nginx/apiCart/2_api.flxblog.club.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 / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://0.0.0.0:8000;
}
}
4.主域名配置https 证书
server {
# SSL configuration
#
listen 443;
ssl on; # 1.1版本后这样写
server_name www.flxblog.club; #填写绑定证书的域名
ssl_certificate /etc/nginx/httpsCart/1_www.flxblog.club_bundle.crt; # 指定证书的位置,绝对路径
ssl_certificate_key /etc/nginx/httpsCart/2_www.flxblog.club.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 / {
#网站主页路径。此路径仅供参考,具体请您按照实际目录操作。
root /var/www/html;
index index.html index.htm;
}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
server {
listen 80;
listen [::]:80;
server_name www.flxblog.club;
location / {
rewrite (.*) https://www.flxblog.club$1 permanent;
}
}
5.最后重新加载配置文件 nginx -s reload