user www www;
worker_processes 8;
error_log
/data1/logs/nginx_error.log crit;
pid
/usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum
file descriptors that can be opened by this process.
worker_rlimit_nofile
51200;
events
{
use epoll;
worker_connections
51200;
}
http
{
include mime.types;
#默认类型二进制数据流
default_type application/octet-stream;
#charset
gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
#gzip
on;
#gzip_min_length 1k;
#gzip_buffers 4 16k;
#gzip_http_version 1.0;
#gzip_comp_level 2;
#gzip_types
text/plain application/x-javascript text/css application/xml;
#gzip_vary
on;
upstream info.ch.gongchang.com {
server
192.168.0.58;
}
upstream ch.gongchang.com {
server 192.168.0.58;
}
upstream
p.ch.gongchang.com {
server 192.168.0.58;
}
server
{
listen 80;
server_name www.sjgc.com;
proxy_redirect off;
#后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
proxy_set_header
X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
location /{
proxy_pass http://ch.gongchang.com;
}
location ^~ /trade/{
proxy_pass
http://ch.gongchang.com;
}
location ^~ /company/{
proxy_pass http://ch.gongchang.com;
}
location ^~ /buy/{
proxy_pass
http://ch.gongchang.com;
}
#定义日志格式
log_format access '$remote_addr -
$remote_user [$time_local] $request '
'"$status"
$body_bytes_sent "$http_referer" '
'"$http_user_agent"
"$http_x_forwarded_for"';
#打日志
access_log
/data1/logs/wwwlogs.log access;
#允许客户端请求的最大的单个文件字节数
client_max_body_size 10m;
#缓冲区代理缓冲用户端请求的最大字节数
可以理解为先保存到本地再传给用户
client_body_buffer_size 128k;
#跟后端服务器连接的超时时间_发起握手等候响应超时时间
proxy_connect_timeout
600;
#连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之中等候处理
proxy_read_timeout 600;
#后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据
proxy_send_timeout 600;
#代理请求缓存区_这个缓存区间会保存用户的头信息以供Nginx进行规则处理_一般只要能保存下头信息即可
proxy_buffer_size 8k;
#同上
告诉Nginx保存单个用的几个Buffer 最大用多大空间
proxy_buffers 4 32k;
#如果系统很忙的时候可以申请更大的proxy_buffers 官方推荐*2
proxy_busy_buffers_size 64k;
#proxy缓存临时文件的大小
proxy_temp_file_write_size 64k;
}
server
{
listen 80;
server_name www.info.sjgc.com;
proxy_redirect off;
location / {
proxy_pass http://info.ch.gongchang.com;
proxy_set_header X-Real-IP
$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
location /cggs/
{
rewrite ^/cggs/(.*)$ /chenggonggushi/$1 break;
proxy_pass http://info.ch.gongchang.com;
proxy_set_header X-Real-IP
$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
log_format blog_s135_com '$remote_addr - $remote_user
[$time_local] $request '
'"$status"
$body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log
/data1/logs/blog.log blog_s135_com;
}
server
{
listen 80;
server_name
www.p.sjgc.com;
proxy_redirect
off;
location / {
proxy_pass http://p.ch.gongchang.com;
proxy_set_header X-Real-IP
$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
location ^~ /user/{
proxy_pass http://p.ch.gongchang.com;
}
log_format blog_s135_commm '$remote_addr - $remote_user
[$time_local] $request '
'"$status"
$body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log
/data1/logs/blog.log blog_s135_com;
}
}