Use Nginx as a normal proxy server. Please do not use it for illegal purposes.
As a reverse proxy tool, nginx can be used as a proxy tool in addition to reverse proxy. The steps for using it as a proxy tool are as follows. This configuration currently supports proxying for websites accessing the http protocol. This configuration is not available for the time being. Support https
-
Windows system proxy settings correspond to IP, port 8011
-
Log configuration:
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":"192.168.11.11","remote_user":"-","request":"GET http://192.168.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","192.168.11.11","c-xxx", "192.168.2.2","192.168.2.2:17000", "/?t=123", "GET"}
- Agent configuration:
server {
listen 8011;
server_name 192.168.11.11 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;
}
}