nginx笔记---1

linux 简易安装教程:

安装make 	
yumy  -y install gcc automake autoconf libtool make
安装gcc
yum install gcc gcc-c++

安装相关依赖
yum -y install pcre-devel  openssl openssl-devel zlib-devel

安装nginx
wget http://nginx.org/download/nginx-1.14.2.tar.gz

tar -zxvf nginx-1.14.2.tar.gz

cd nginx-1.4.2

./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/opt/app/openet/oetal1/chenhe/pcre-8.37 \
--with-zlib=/opt/app/openet/oetal1/chenhe/zlib-1.2.8 \
--with-openssl=/opt/app/openet/oetal1/chenhe/openssl-1.0.1t

make

make instal

 

配置文件:

结构

#开始

event{

}

http{

   server{

            }

    server{

             }

}

#结束

 

 

1.user  user group                 nginx Worker进程的用户个组

2.worker_processes    4           进程数

3.worker_rlimit_nofile    52100  文件描述符数量

 events

{

4. worker_connections   52100  允许的连接数

  }

http

{

5.client_max_body_size 8m   上传文件大小限制

 

6.gzip  on   开启压缩

}

 

1.目录控制中自动列出目录.

 location / {
   autoindex on;
}

2. 控制页面缓存时间

location  / {
 expires 30d;
}

3. 负载均衡、容灾配置

upstream test_pool{
	 server localhost:8080 weight=1  max_fails=2 fail_timeout=5s;
	 server localhost:8082 weight=1 max_fails=2 fail_timeout=5s;
	}
	
	server {
	listen        8000;
	server_name   localhost;

	location / {
	proxy_next_upstream http_404  http_500 timeout  error invalid_header;
    proxy_pass http://test_pool;

	    }
	
	}

4.设置真实地址

proxy_set_header Host $host;  
	proxy_set_header X-Forwarded_For $remote_addr;

5.同一个ip落到同一个server

upstream test_pool{
	 ip_hash;
	 server localhost:8080  max_fails=2 fail_timeout=5s;
	 server localhost:8082  max_fails=2 fail_timeout=5s;
	}


摘除某一个
upstream test_pool{
	 ip_hash;
	 server localhost:8080  max_fails=2 fail_timeout=5s down;
	 server localhost:8082  max_fails=2 fail_timeout=5s;
	}

6.日志配置

http{
#定义格式
 log_format combined1 'log:-remote_addr:$remote_addr - remote_user:$remote_user time_local:[$time_local] request:"$request" '
                      'status:$status body_bytes_sent:$body_bytes_sent "http_referer:$http_referer" '
                      '"http_user_agent:$http_user_agent" http_x_forwarded_for:"$http_x_forwarded_for"';
}

server{
#申明位置和格式
access_log logs/index.log combined1;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值