nginx proxy模块

nginx proxy模块

环境:

user:192.168.100.169

nginx代理:192.168.100.175

tomcat:192.168.100.175

域名:www.vijay.com  —>192.168.100.175

1.nginx配置

proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_redirect off;
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_set_header http_user_agent $http_user_agent;    //判断访问端是苹果,安卓,win还是mac

proxy_next_upstream http_502 http_504 http_503 error timeout invalid_header;  //请求出错后,转向下一个节点

 

2.web服务器端日志配置(如tomcat)

192.168.100.175 192.168.100.169 192.168.100.169 192.168.100.175 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) – – [12/May/2016:19:25:28 +0800] “GET /bg-button.png HTTP/1.0” 304 –
192.168.100.175 192.168.100.169 192.168.100.169 192.168.100.175 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) – – [12/May/2016:19:25:28 +0800] “GET /asf-logo.png HTTP/1.0” 304 –
192.168.100.175 192.168.100.169 192.168.100.169 192.168.100.175 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) – – [12/May/2016:19:25:28 +0800] “GET /bg-middle.png HTTP/1.0” 304 –
192.168.100.175 192.168.100.165 192.168.100.165 192.168.100.175 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.56 (KHTML, like Gecko) Version/9.0 Safari/601.1.56 – – [12/May/2016:19:27:51 +0800] “GET / HTTP/1.0” 200 11230
192.168.100.175 192.168.100.165 192.168.100.165 192.168.100.175 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.56 (KHTML, like Gecko) Version/9.0 Safari/601.1.56 – – [12/May/2016:19:27:51 +0800] “GET /tomcat.css HTTP/1.0” 200 5576
192.168.100.175 192.168.100.165 192.168.100.165 192.168.100.175 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.56 (KHTML, like Gecko) Version/9.0 Safari/601.1.56 – – [12/May/2016:19:27:51 +0800] “GET /tomcat.png HTTP/1.0” 200 5103
192.168.100.175 192.168.100.165 192.168.100.165 192.168.100.175 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.56 (KHTML, like Gecko) Version/9.0 Safari/601.1.56 – – [12/May/2016:19:27:51 +0800] “GET /bg-nav.png HTTP/1.0” 200 1401

备注:

未经允许不得转载:淘淘源码吧 » nginx proxy模块