内容简介:在证书控制台下载 Nginx 版本证书。下载到本地的压缩文件包解压后包含:1、在 Nginx 的安装目录下创建 cert 目录,并且将下载的全部文件拷贝到 cert 目录中,如果申请证书时是自己创建的CSR文件,请将对应的私钥文件放到 cert 目录下。2、打开 Nginx 安装目录下 conf 目录中的 nginx.conf 文件
在证书控制台下载 Nginx 版本证书。下载到本地的压缩文件包解压后包含:
- .pem 文件:证书文件
- .key 文件:证书的私钥文件(申请证书时如果没有选择 自动创建CSR ,则没有该文件)
配置Nginx
1、在 Nginx 的安装目录下创建 cert 目录,并且将下载的全部文件拷贝到 cert 目录中,如果申请证书时是自己创建的CSR文件,请将对应的私钥文件放到 cert 目录下。
2、打开 Nginx 安装目录下 conf 目录中的 nginx.conf 文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on; #开启gzip
gzip_min_length 1k; #低于1kb的资源不压缩
gzip_comp_level 3; #压缩级别【1-9】,越大压缩率越高,同时消耗cpu资源也越多,建议设置在4左右。
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css; #需要压缩哪些响应类型的资源,多个空格隔开。不建议压缩图片,下面会讲为什么。
gzip_disable "MSIE [1-6]\."; #配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)
gzip_vary on; #是否添加“Vary: Accept-Encoding”响应头
server {
listen 80 default backlog=2048; #配置http可用
listen 443 ssl; #配置https
server_name localhost;
ssl_certificate ../cert/hzzly.pem; #配置证书文件
ssl_certificate_key ../cert/hzzly.key; #配置私钥文件
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /home/hzzly;
index index.html index.htm;
}
# location ^~ /apis/ {
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-Server $host;
# # 匹配任何以 /apis/ 开始的请求,并停止匹配 其它location
# proxy_pass http://xxxxxxxxxx/;
# }
# location ^~ /assets/ {
# gzip_static on;
# expires max;
# add_header Cache-Control public;
# }
}
}
3、重启 Nginx
$ cd /usr/local/nginx/sbin $ ./nginx -s reload
错误详解
1、Nginx如果未开启SSL模块,配置Https时提示错误
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in ...
Nginx开启SSL模块
切换到源码包:
$ cd /usr/local/src/nginx-1.16.0
修改新的configure参数
$ ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
配置完成后,运行命令
$ make //这里不要进行make install,否则就是覆盖安装
备份原有已安装好的nginx
$ cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
将刚刚编译好的nginx覆盖掉原有的nginx
$ cp ./objs/nginx /usr/local/nginx/sbin/
重启 Nginx
$ cd /usr/local/nginx/sbin $ ./nginx -s reload
以上所述就是小编给大家介绍的《Nginx下升级https》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- CDH升级指南|推荐升级四部曲之 CDH 升级重头戏,收藏了!
- 推荐升级四部曲之 CDH 手动升级,奔涌吧!
- Windows Insider 最新重大升级,升级记事本应用
- 全站HTTPS升级系列(一)升级前的科普工作
- 详解:君士坦丁堡升级再遇安全“漏洞” 为何官方照常升级?
- 如何从 Java 8 升级到 Java 12,升级收益及问题处理技巧
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
菜鸟侦探挑战数据分析
[日] 石田基广 / 支鹏浩 / 人民邮电出版社 / 2017-1 / 42
本书以小说的形式展开,讲述了主人公俵太从大学文科专业毕业后进入征信所,从零开始学习数据分析的故事。书中以主人公就职的征信所所在的商业街为舞台,选取贴近生活的案例,将平均值、t检验、卡方检验、相关、回归分析、文本挖掘以及时间序列分析等数据分析的基础知识融入到了生动有趣的侦探故事中,讲解由浅入深、寓教于乐,没有深奥的理论和晦涩的术语,同时提供了大量实际数据,使用免费自由软件RStudio引领读者进一步......一起来看看 《菜鸟侦探挑战数据分析》 这本书的介绍吧!