Nginx核心知识100讲学习笔记(陶辉):初始Nginx(三)
一、SSL 证书的公信力是如何保证的?
1、证书类型
2、证书链
二、SSL 协议握手时 Nginx 的性能瓶颈在哪里?
1、TLS通讯过程
2、nginx握手性能
3、nginx数据加密性能
4、nginx综合性能
三、用免费 SSL 证书实现一个 HTTPS 站点
1、安装
1 | [root@luoahong conf] # yum install certbot python2-certbot-nginx -y |
2、配置
1 2 | [root@luoahong conf] # certbot --nginx --nginx-server-root=/usr/local/openresty/nginx/conf/ -d www.luoahong.com ...... |
3、nginx配置
增加如下配置
1 2 3 4 5 | listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/pazzn .com /fullchain .pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/pazzn .com /privkey .pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx .conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams .pem; # managed by Certbot |
四、基于 OpenResty 用 Lua 语言实现简单服务
1、下载OpenResty
1 | [root@luoahong src] # wget https://openresty.org/download/openresty-1.13.6.2.tar.gz |
2、分析目录结构
1、比nginx看起来少了很多东西,少的的东西到底在哪?
1 2 3 4 5 6 7 8 9 10 | [root@luoahong openresty-1.13.6.2] # ll total 108 drwxrwxr-x. 43 1000 1000 4096 May 15 2018 bundle #少的东西在这 -rwxrwxr-x. 1 1000 1000 48140 May 15 2018 configure -rw-rw-r--. 1 1000 1000 22924 May 15 2018 COPYRIGHT -rw-r--r--. 1 root root 5572 Mar 1 09:02 Makefile drwxrwxr-x. 2 1000 1000 156 May 15 2018 patches -rw-rw-r--. 1 1000 1000 4689 May 15 2018 README.markdown -rw-rw-r--. 1 1000 1000 8972 May 15 2018 README-windows.txt drwxrwxr-x. 2 1000 1000 52 May 15 2018 util |
2、openresty是基于那个nginx版本开发
1 2 3 4 5 6 | [root@luoahong openresty-1.13.6.2] # cd bundle/ [root@luoahong bundle] # ls ..... encrypted-session-nginx-module-0.08 nginx-1.13.6 #是基于这个版本开发的 ...... lua-resty-upload-0.10 xss-nginx-module-0.06 |
3、集成了很多第三方模块 是作者张亦春写的
1 2 3 4 5 6 7 8 9 10 11 12 13 | [root@luoahong bundle] # ls ...... lua-redis-parser-0.13 opm-0.0.5 lua-resty-core-0.1.15 pod lua-resty-dns-0.21 rds-csv-nginx-module-0.09 lua-resty-limit-traffic-0.05 rds-json-nginx-module-0.15 lua-resty-lock-0.07 redis2-nginx-module-0.15 lua-resty-lrucache-0.08 redis-nginx-module-0.3.7 lua-resty-memcached-0.14 resty-cli-0.21 lua-resty-mysql-0.20 resty.index lua-resty-redis-0.26 set -misc-nginx-module-0.32 lua-resty-string-0.11 srcache-nginx-module-0.31 lua-resty-upload-0.10 xss-nginx-module-0.06 |
3、编译
1、nginx的第三方模块C模块 lua代码编写的 我们编译主要是编译c目录
1 | [root@luoahong openresty-1.13.6.2] # ./configure --help|more |
2、核心模块能不能移除
1 2 | --without-http_lua_module disable ngx_http_lua_module --without-http_lua_upstream_module disable ngx_http_lua_upstream_module |
4、添加Lua代码
1、如何把lua代码添加到openrester中
1 2 3 4 5 6 7 8 9 10 | [root@luoahong conf] # pwd /usr/local/openresty/nginx/conf [root@luoahong conf] # vim nginx.conf 添加如下: location /lua { default_type text /html ; content_by_lua 'ngx.say("User-Agent: ", ngx.req.get_headers()["User-Agent"])' ; } |
与lua不一致所以不能直接复制过来
5、运行
1 2 3 4 5 6 7 | [root@luoahong conf] # ../sbin/nginx root@luoahong conf] # ps -ef|grep nginx root 18979 1 0 Mar02 ? 00:00:00 nginx: master process .. /sbin/nginx nobody 18980 18979 0 Mar02 ? 00:00:00 nginx: worker process nobody 18981 18979 0 Mar02 ? 00:00:00 nginx: worker process nobody 18982 18979 0 Mar02 ? 00:00:01 nginx: cache manager process root 19521 18910 0 10:58 pts /0 00:00:00 grep --color=auto nginx |
访问测试截图
作者:罗阿红
出处:http://www.cnblogs.com/luoahong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
分类:
深挖计算机基础
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构