Nginx核心知識100講學習筆記(陶輝):初始Nginx(三)


一、SSL 證書的公信力是如何保證的?

1、證書類型

2、證書鏈

 

二、SSL 協議握手時 Nginx 的性能瓶頸在哪里?

1、TLS通訊過程

2、nginx握手性能

3、nginx數據加密性能

4、nginx綜合性能

三、用免費 SSL 證書實現一個 HTTPS 站點

1、安裝

[root@luoahong conf]# yum install certbot python2-certbot-nginx -y

2、配置

[root@luoahong conf]# certbot --nginx --nginx-server-root=/usr/local/openresty/nginx/conf/ -d www.luoahong.com
......

3、nginx配置

增加如下配置

    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

[root@luoahong src]# wget https://openresty.org/download/openresty-1.13.6.2.tar.gz

2、分析目錄結構

1、比nginx看起來少了很多東西,少的的東西到底在哪?

[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版本開發

[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、集成了很多第三方模塊 是作者張亦春寫的

[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目錄

[root@luoahong openresty-1.13.6.2]# ./configure --help|more

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中

[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、運行

[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

訪問測試截圖


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM