可以通过配置 Nginx 使其作为正向代理并通过代理程序访问目标服务器。
配置 Nginx 作为正向代理
-  安装 Nginx(如果尚未安装): sudo apt update sudo apt install nginx
-  配置 Nginx: 
 打开 Nginx 的配置文件进行编辑:sudo nano /etc/nginx/nginx.conf
-  添加正向代理配置: 
 在http块中添加如下内容:http {server {listen 8888;location / {proxy_pass $scheme://$host$request_uri;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}} }这段配置将 Nginx 设置为一个通用的正向代理服务器。 
-  重启 Nginx: 
 保存配置文件并重启 Nginx 使配置生效:sudo nginx -t sudo systemctl restart nginx
配置程序通过代理访问
为了让程序通过代理访问目标服务器,您可以配置程序使用 192.142.8.82:8888 作为代理服务器。如果不能配置环境变量,可以在程序代码中显式指定代理设置。
示例:使用 curl 命令通过代理访问
 
如果无法通过环境变量配置,可以使用 curl 的代理参数进行访问:
curl -x http://192.142.8.82:8888 http://172.26.73.51:13001
curl -x http://192.142.8.82:8888 http://172.26.61.129:80
示例:在 Python 程序中使用代理
如果您有一个 Python 程序,需要通过代理访问,可以使用 requests 库配置代理:
import requestsproxies = {"http": "http://192.142.8.82:8888"