在Nginx下配置SSL证书
来源:互联网 发布:网络流量监视软件 编辑:程序博客网 时间:2024/06/06 01:02
首先通过SFTP链接你的网站服务器,然后找到 /usr/local/nginx/conf/vhost/域名.conf
文件并下载到本地(以 hello.cn.conf 为例)。
然后我们本地打开 hello.cn.conf 文件并修改,下面是修改后的完整配置文件示例:
(注意:只需要看18行以前就行了,后面的不要跟着示例走,以前是什么就是什么,不需要和示例一模一样。)
server { listen 80; listen 443 ssl http2; ssl on; ssl_certificate /root/hello.cn.crt; ssl_certificate_key /root/hello.cn.key; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000"; server_name hello.cn; index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/hello.cn; if ( $scheme = http ){ return 301 https://$server_name$request_uri; }# 只需要看前面的代码就行了,后面的不需要和示例一致!!! include none.conf; #error_page 404 /404.html; location ~ [^/]\.php(/|$) { # comment try_files $uri =404; to enable pathinfo try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; #include pathinfo.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log off; }
修改并保存后,上传 hello.cn.conf
到 /usr/local/nginx/conf/vhost
文件夹并覆盖原文件(注意备份)。
然后再把 hello.cn.crt、hello.cn.key
上传到 hello.cn.conf
文件中指定的地方,比如示例中的 /root
文件夹下。
然后SSH链接网址服务器并重启Nginx
如果你不需要访客强制访问 HTTPS ,那么不需要添加这段代码。
if ( $scheme = http ){ return 301 https://$server_name$request_uri; }
0 0
- 在Nginx下配置SSL证书
- Nginx 下配置SSL证书的方法
- Nginx下配置Comodo Essential SSL证书
- nginx配置ssl证书
- NGINX 配置双向SSL 证书
- nginx 配置自制SSL证书
- SSL证书的购买与Nginx下的配置-转载
- CentOS7下Let's Encrypt Nginx配置SSL证书
- 在Nginx上配置Comodo Positive SSL证书
- 在LNMP或Nginx上配置NameCheap免费SSL证书
- nginx下如何配置 ssl证书?腾讯云ssl证书为例!
- Nginx配置ssl证书(中间证书)
- nginx配置和ssl证书的配置
- nginx配置ssl双向验证 nginx https ssl证书配
- Nginx 配置 SSL 证书 + HTTPS 站点小记
- Nginx + https + 免费SSL证书配置指南
- Nginx 配置 SSL 证书 + HTTPS 站点
- Godaddy SSL 证书配置(Nginx)
- opencv学习之仿射变换
- MDK工程的文件类型以及产生过程解析
- 取余与位运算
- 解决 Redis 只读不可写的问题
- 凌乱的yyy
- 在Nginx下配置SSL证书
- fir.im Weekly
- P1008 三连击(洛谷)
- 20170128C语言提升02_结构体和union和void
- UVa 272:TEX Quotes
- mysql索引详解
- python 8-1 如何使用多线程,Thread创建线程,执行函数赋值给target//类+函数放在run方法中执行
- UVa 10082:WERTYU
- 栈应用之中缀转后缀表达式(C语言版)