oneinstack Java环境 Nginx安装ssl证书 (LNMT : Linux + Nginx+ MySQL/MongoDB+ Tomcat)
使用的是阿里云免费DV证书,单个域名
1.下载ssl审核通过的证书 使用nginx版本
2.nginx 文件配置 和 证书存放
server { listen 80; listen [::]:80; listen 443 ssl; ssl_certificate cert/3919775_video.xiaoxiao.cool.pem; ssl_certificate_key cert/3919775_video.xiaoxiao.cool.key; server_name video.xiaoxiao.cool; access_log /data/wwwlogs/video.xiaoxiao.cool_nginx.log combined; index index.html index.htm index.jsp; root /data/wwwroot/video.xiaoxiao.cool; #自动跳转 if($server_port = 80 ){ rewrite ^(.*)$ https://$host$1 permanent; } #error_page 404 /404.html; #error_page 502 /502.html; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) { deny all; } location ~ { proxy_pass http://127.0.0.1:8080; include proxy.conf; } }
证书存放路径
配置好reload一下,就完成了
service nginx reload