建设银行网站功能介绍手把手教你优化网站
使用Nginx作为一个普通代理服务器, 请不要用于违法用途哦
nginx作为一个反向代理工具,除了可以进行反向代理之外,还可以用来作为代理工具来使用,作为代理工具使用的步骤如下,这个配置目前支持80端口
-
Windows系统代理设置对应IP, 端口8011
-
日志配置:
http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';# access_log logs/access.log main;
log_format json '{"remote_addr":"$remote_addr","remote_user":"$remote_user",''"request":"$request","status":"$status","remote_user":"$bytes_sent",''"http_referer":"$http_referer","http_user_agent":"$http_user_agent","$server_name","$hostname", "$host","$http_host", "$request_uri", "$request_method"}';access_log D:/data/logs/nginx/nginx-access.log json buffer=1k;}
对应请求日志:
{"remote_addr":"172.62.1.2","remote_user":"-","request":"GET http://172.62.2.2:17000/?t=123 HTTP/1.1","status":"200","remote_user":"97103","http_referer":"-","http_user_agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36","172.62.1.2","c-xxx", "172.62.2.2","172.62.2.2:17000", "/?t=123", "GET"}
- 代理配置:
server {listen 8011;server_name 172.62.1.2 localhost;#charset koi8-r;# access_log D:/develop/nginx/nginx-v1.21.5-2/nginx-1.21.5/logs/host.access.log main;location / {proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://$http_host$request_uri;}
}