nginx根据客户端ip进行简单转发(回发)
2012-08-23 15:12
736 查看
配置文件下载路径:下载
配置文件default.vhosts.conf:
配置文件default.vhosts.conf:
log_format ie '$remote_addr [$time_local:$msec] "POST $request_uri&$request_body HTTP/1.0" "$http_referer" "$http_user_agent"'; log_format customed_ie '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'; server { include vhosts/vhosts.listen.addr; if ($remote_addr ~* "10.11.202.181") { rewrite ^/(.*) http://$remote_addr:8080/$1; #根据ip匹配,回发给自己 } location ~ ^/post { proxy_pass http://localhost:9999; access_log logs/ie_access_log ie; #记录日志 } location = /q { proxy_pass http://localhost:9999; access_log logs/ie_access_log ie; #记录日志 } location ~ .*\.php$ { include fastcgi.conf; fastcgi_pass localhost:9000; fastcgi_index index.php; access_log logs/getrank_access_log ie; #记录日志 } location / { access_log logs/ie_access_log customed_ie; #记录日志 } }配置文件nginx.conf:
user nobody nobody; worker_processes 8; working_directory /search/nginx/core; worker_rlimit_core 2G; #error_log logs/error.log error; error_log logs/error.log debug; pid sbin/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; set_real_ip_from 10.15.4.0/24; set_real_ip_from 10.12.0.0/16; set_real_ip_from 10.11.0.0/16; set_real_ip_from 10.10.0.0/16; set_real_ip_from 10.14.0.0/16; set_real_ip_from 10.13.0.0/16; real_ip_header X-Real-IP; include xnet.conf; log_format main '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent $request_time "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; log_format mini '$time_local $status $body_bytes_sent $request_time $upstream_cache_status $server_name'; access_log logs/access_log main; access_log logs/status_log mini; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 20m; sendfile on; tcp_nopush on; tcp_nodelay on; #keepalive_timeout 30; send_timeout 300; proxy_next_upstream error timeout; proxy_connect_timeout 2; proxy_read_timeout 5; #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; #gzip on; proxy_cache_path /dev/shm/nginx/cache2/ levels=2:2 keys_zone=sogou-cache2:154m max_size=1g inactive=24h ; proxy_cache_path /dev/shm/nginx/cache/ levels=2:2 keys_zone=sogou-cache:308m max_size=3g inactive=72h ; proxy_temp_path /dev/shm/nginx/temp/; fastcgi_cache_path /search/nginx/fastcgi_cache/ levels=2:2 keys_zone=sogou-fccache:128m max_size=4g inactive=72h ; fastcgi_temp_path /search/nginx/fastcgi_temp/; include vhosts/*.conf; }
相关文章推荐
- nginx根据客户端ip地理位置转发到不同服务器上(Geoip+nginx)
- 服务器控件在客户端触发alert对话框后,根据情况进行回发服务器操作
- nginx 根据IP 进行灰度发布
- nginx根据$remote_addr分发 (客户端IP)
- IpHelper根据客户端IP进行网站分流
- 根据IP(有代理的情况)定位城市以及通过nginx转发的tomcat如何得到用户真实的ip
- nginx 根据IP 进行灰度发布
- nginx 根据IP 进行灰度发布 推荐
- nginx针对客户端ip进行限制:外网访问需要密码认证
- nginx对根据ip尾数转发分流
- nginx 配置域名转发和进行ip限制
- IpHelper 根据客户端IP进行网站分流
- nginx 根据IP 进行灰度发布
- nginx 根据IP 进行灰度发布
- nginx根据域名转发不同ip端口
- nginx根据客户端ip动态代理后端服务-TCP
- Node.js 获取客户端IP, 以及nginx转发携带客户端ip配置
- nginx根据$remote_addr分发 nginx根据客户端IP分发
- nginx做反向负载均衡,后端服务器获取真实客户端ip
- nginx之如何获取真实客户端ip