赞
踩
正向代理是一个位于客户端和原始服务器之间的服务器,为了从原始服务器取得内容,客户端向代理发送一个请求并指定目标(原始服务器),然后代理向原始服务器转交请求并将获得的内容返回给客户端。
配置nginx.conf正向代理
- user nginx;
- worker_processes auto;
-
- error_log /var/log/nginx/error.log notice;
- pid /var/run/nginx.pid;
-
-
- events {
- worker_connections 1024;
- }
-
-
- http {
- include /etc/nginx/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 /var/log/nginx/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- keepalive_timeout 65;
-
- #gzip on;
-
- include /etc/nginx/conf.d/*.conf;
- }
#构建容器
docker run --name proxy-nginx -d --network=host -v /app/nginx/nginx.conf:/etc/nginx/nginx.conf -v /app/nginx/conf.d:/etc/nginx/conf.d -v /app/nginx/html:/etc/nginx/html 192.168.9.125/library/nginx:proxy_1.21.6
#测试正向代理
curl https://www.baidu.com -v -x 127.0.0.1:10001
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。