英文:
Have supervisor run via http_proxy list
问题
我目前有一个使用golang编写的程序,我有一个类似以下的监控配置文件:
[program:yout_go]
command = /bin/sh -c 'http_proxy=user:password@123.123.123.123 /home/www/program -env prod'
directory = /home/www/
enviroment=PATH='/home/www/env/bin:/usr/bin'
user = user
autorestart = true
stderr_logfile = /var/log/program/err.log
stdout_logfile = /var/log/program/out.log
目前我通过一个代理运行它,但我想让它通过更多的代理运行。
有没有办法可以实现这个?比如让http_proxy从代理列表中获取,还是我必须让goprogram自己处理?
英文:
I current have a golang program that I have a supervisor config file like such
[program:yout_go]
command = /bin/sh -c 'http_proxy=user:password@123.123.123.123 /home/www/program -env prod'
directory = /home/www/
enviroment=PATH='/home/www/env/bin:/usr/bin'
user = user
autorestart = true
stderr_logfile = /var/log/program/err.log
stdout_logfile = /var/log/program/out.log
Currently I am running it via 1 proxy, but I want to have it run through more proxies.
Is there any way I can do this? Such as having the http_proxy pull from a list of proxies or do I have to make the goprogram run through it?
答案1
得分: 2
Go的http包使用HTTP_PROXY
、HTTPS_PROXY
和NO_PROXY
环境变量,就像其他程序一样,并且查找一个单独的URL。
如果你想要在多个代理之间轮换,你需要为你的http.Transport
提供一个自定义的Proxy
函数,而不是依赖于默认的http.ProxyFromEnvironment
函数。
英文:
The Go http package uses the HTTP_PROXY
, HTTPS_PROXY
and NO_PROXY
environment variables like other programs, and looks for a single url.
If you want to rotate through multiple proxies, you need to provide a custom Proxy
function to your http.Transport
, rather than rely on the default http.ProxyFromEnvironment
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论