请主管通过 http_proxy 列表运行。

huangapple go评论74阅读模式
英文:

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_PROXYHTTPS_PROXYNO_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.

huangapple
  • 本文由 发表于 2016年2月19日 01:33:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/35488486.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定