nginx学习

上一篇 / 下一篇  2014-02-17 17:34:13 / 个人分类:nginx

nginx:主要任务负载均衡和反向代理。
nginx的处理原理:
客户端http请求发送到nginx,nginx的location 对请求进行转发到nginx的handel处理模块(配置选在的处理方式),处理完成后发送给load_balance模块 进行负载均衡发送给对应的机器,机器处理的结果返回给nginx然后由nginx 的过滤模块来过滤信息 ,最后由nginx把处理的处理的结果返回给客户端。

nginx的配置文件:

user              apache; //这个一直不是很理解 的东西,就把它看作 nginx安装时加入的组

worker_processes  4;//提供服务的cpu个数
worker_cpu_affinity 0001 0010 0100 1000; //具体的cpu

error_log  /var/log/nginx/error.log; //错误日志
pid        /var/run/nginx.pid;       //pid的存放目录

//上面这些基本都是固定的配置
events {
    worker_connections 1024;//可以承受的最大连接数
//这个里面其实还有一个配置,nginx的服务机制
}

//http服务配置
http {

    include       /etc/nginx/mime.types;//mime.types文件里罗列了nginx支持的所有文件格式 如html
    default_type  application/octet-stream; //配置默认的类型

    log_format tuan_access '$remote_addr - $remote_user [$time_local] "$request" ,, "$request_body" '
                           '$status $body_bytes_sent "$http_referer" '
                           '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  tuan_access;
  //上面是配置日志和日志的参数
  //下面是连接时间 和超时,缓存等等的配置。
    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  10;
    client_header_timeout 30s;
    client_body_timeout 30s;
    client_max_body_size 100m;
    send_timeout 30s;
    ignore_invalid_headers on;

    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
    fastcgi_keep_conn off;
//fastcgi的服务器 fastcgi和nginx的配置在其他日志介绍
    upstream php_fastcgi_socket {
        server unix:/dev/shm/php-fpm.sock;
    }

    include /etc/nginx/conf.d/*.conf;

}

TAG: nginx Nginx NGINX

 

评分:0

我来说两句

日历

« 2024-05-02  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 12950
  • 日志数: 15
  • 建立时间: 2013-02-27
  • 更新时间: 2014-05-04

RSS订阅

Open Toolbar