nginx主配置文件
[root@csdn-proxy-100 conf]# cat nginx.conf
user nginx nginx; #nginx用户、用户组
worker_processes 8; #运行进程数目
pid /var/run/nginx.pid; #nginx进程pid
worker_rlimit_nofile 65535; #worker进程可以打开的文件数
events {
use epoll; #使用epoll模型
worker_connections 65535; #worker连接数
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 1024;
types_hash_bucket_size 512;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 512;
keepalive_timeout 60;
client_body_buffer_size 512k;
open_file_cache max=65535 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
log_format csdnlog '$remote_addr - $remote_user [$time_iso8601] "$request" '
' "$status" $body_bytes_sent "$http_range" "$http_referer" '
' "$http_user_agent" $http_x_forwarded_for "$request_time" '
' "$host" "$server_port" "$sent_http_location" "$upstream_cache_status"';
include conf.d/*.conf;
}
[root@csdn-proxy-100 conf.d]# ls
vhost.conf
[root@csdn-proxy-100 conf.d]# cat vhost.conf
proxy_redirect off;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 60;
proxy_buffers 32 64k;
proxy_buffer_size 16k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_lock off;
proxy_cache_use_stale updating;
proxy_temp_path /data/nxcache/temp;
proxy_cache_path /data/nxcache/cache1 levels=1:1:2 keys_zone=cache1:1024m max_size=100g inactive=30m;
proxy_cache_path /data/nxcache/cache2 levels=1:1:2 keys_zone=cache2:1024m max_size=100g inactive=30m;
upstream lookepg8080 {
ip_hash ;
#server lookepg.csdn.com:8080;
server 111.13.100.92:8080;
server 111.13.100.93:8080;
server 111.13.100.94:8080;
server 111.13.100.95:8080;
}
upstream lookepg_Played {
# ip_hash ;
server 213.21.205.17:9004;
}
upstream epg {
ip_hash ;
#server epg.csdn.com:8080;
server 114.112.73.194:8080;
server 114.112.73.195:8080;
}
upstream images {
ip_hash ;
#server images.csdn.com:80;
#server 117.79.93.197:80;
server 117.79.93.198:80;
server 117.79.93.199:80;
}
server {
listen *:8080;
server_name lookepg.js.ysten.com;
access_log /nginxlogs/lookepg.access.log csdnlog;
error_log /nginxlogs/error.log;
location ~ (.*)getPlayedHistoryPrograms(.*) {
proxy_pass http://lookepg_Played;
}
location ~ (.*)getServerTime(.*) {
proxy_pass http://lookepg8080;
}
location ~ / {
set $proxykey $request_uri;
if ( $request_uri ~* (.*&)random=([^&]*).* ) {
set $proxykey $1;
}
if ( $request_uri ~* (.*&)radom=([^&]*).* ) {
set $proxykey $1;
}
if ( $request_uri ~* (.*?)random=([^&]*).* ) {
set $proxykey $1;
}
if ( $request_uri ~* (.*?)n=([^&]*).* ) {
set $proxykey $1;
}
proxy_pass http://lookepg8080;
proxy_cache cache5;
#proxy_cache_valid 200 60s;
proxy_cache_valid 200 300s;
proxy_cache_valid any 0;
proxy_ignore_headers "Cache-Control";
proxy_hide_header "Cache-Control";
proxy_ignore_headers "Expires";
proxy_hide_header "Expires";
proxy_cache_key "$proxykey";
proxy_cache_lock on ;
proxy_cache_lock_timeout 10s;
proxy_cache_use_stale updating;
add_header Nginx-Cache "$upstream_cache_status";
}
}
server {
listen *:8080;
server_name epg.csdn.com
access_log /nginxlogs/epg.access.log csdnlog;
error_log /nginxlogs/error.log;
location / {
proxy_pass http://epg;
proxy_read_timeout 60;
proxy_cache cache1;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 206 304 20m;
proxy_cache_valid 404 1s;
add_header Nginx-Cache "$upstream_cache_status";
}
location ~ ((?:\/yst-epg\/panel\/.*style.*.xml)|(?:\/yst-epg\/panel\/.*data.*.xml)){
proxy_pass http://epg;
proxy_read_timeout 60;
proxy_cache cache1;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 206 304 10m;
proxy_cache_valid 404 1s;
add_header Nginx-Cache "$upstream_cache_status";
}
}
server {
listen *:80;
server_name images.csdn.com;
access_log /nginxlogs/images.access.log csdnlog;
error_log /nginxlogs/error.log;
location / {
proxy_pass http://images;
proxy_read_timeout 60;
proxy_cache cache2;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 1d;
proxy_cache_valid 404 1s;
add_header Nginx-Cache "$upstream_cache_status";
}
location /nginx_status {
stub_status on;
access_log off;
allow all;
#allow 127.0.0.1;
#deny all;
}
}