nginx

1.Nginx的程序架构:
        master/worker
           
一个master进程:
               
负载加载和分析配置文件、管理worker进程、平滑升级
           
一个或多个worker进程
               
处理并响应用户请求
           
缓存相关的进程:
                cache loader
:载入缓存对象
                cache manager
:管理缓存对象
               
       
特性:异步、事件驱动和非阻塞
           
并发请求处理:通过epoll/select
           
文件IO:高级IO sendfile,异步,mmap
           
2. nginx
模块:高度模块化,但其模块早期不支持DSO机制;近期版本支持动态装载和卸载;
           
模块分类:
               
核心模块:core module
               
标准模块:
                    HTTP modules

                        Standard HTTP
modules
                        Optional HTTP
modules
                    Mail modules
                    Stream modules

                       
传输层代理
                3rd party modules
               
   nginx
的功用:
           
静态的web资源服务器;(图片服务器,或js/css/html/txt等静态资源服务器)
           
结合FastCGI/uwSGI/SCGI等协议反代动态资源请求;
            http/https
协议的反向代理;
            imap4/pop3
协议的反向代理;
            tcp/udp
协议的请求转发;
           
    nginx
的安装配置:
       
官方的预制包:
            http://nginx.org/packages/centos/7/x86_64/RPMS/
            Fedora-EPEL:

3.程序环境

            配置文件的组成部分:
               
主配置文件:nginx.conf
                    include
conf.d/*.conf
                fastcgi
uwsgiscgi等协议相关的配置文件
                mime.types
:支持的mime类型
           
主程序文件:/usr/sbin/nginx
            Unit File
nginx.service
       
       
配置:
           
主配置文件的配置指令:
                directive value [value2
…];
               
               
注意:
                    (1)
指令必须以分号结尾;
                    (2)
支持使用配置变量;
                       
内建变量:由Nginx模块引入,可直接引用;
                       
自定义变量:由用户使用set命令定义;
                            set
variable_name value;
                           
引用变量:$variable_name
                                   
                           
           
主配置文件结构:
                main block
:主配置段,也即全局配置段;
                    event {
                        …
                    }
:事件驱动相关的配置;
                http {
                    …
                }
http/https 协议相关的配置段;
                mail {
                    …
                }
                stream {
                    …
                }
           
            http
协议相关的配置结构
                http {
                    …
                    …
:各server的公共配置
                    server {
                        …
                    }
:每个server用于定义一个虚拟主机;
                    server {
                        …
                        listen
                        server_name
                        root
                        alias
                        location
[OPERATOR] URL {
                            …
                            if CONDITION
{
                                …
                            }
                        }
                    }

4.建一个nginx服务器

nginx

nginx

nginxnginx

nginx

nginx

5.性能优化,如果一台主机只服务nginx,绑定cpu,调优先级及最大调优

nginx

nginx

6.限制条件访问

nginx

在172.16.254.177上访问 403

nginx

7.图片限制访问

nginx

nginx

nginx

nginx

8.root与alias区别

nginx

nginx

nginx

nginx

nginx

nginx

nginx

nginx

9.错误页面重新定义

nginx

nginx

nginx

nginx

nginx

10.认证登录设置

nginx

nginx

nginx

nginx

11.状态页访问

nginx

nginx

12. 日志定义

nginx

nginx

13. gzip压缩模块

nginx

nginx

 

14。ssl 模块

(1)在另外台主机上

nginx

(2)在另外nginx那台主机上

nginx

nginx

(3)在CA主机上

nginx

nginx

(3)在nginx主机上

nginx

nginx

15.rewirte模块

nginx

nginx

nginx

nginx

原创文章,作者:yaobinbin,如若转载,请注明出处:http://www.178linux.com/78228

(0)
yaobinbinyaobinbin
上一篇 2017-06-19
下一篇 2017-06-19

相关推荐