【发布时间】:2016-12-16 22:23:24
【问题描述】:
我正在努力从在 docker 容器代理 http 请求上运行的 web api 获取我的 http 调用。我已经使用 bash 通过代理成功到达了所需的端点
docker exec -i -t 665b4a1e17b6 /bin/bash
和
http_proxy=http://exampleProxy:7777 curl -s http://endpoint
现在我想在同一个容器上运行的应用程序中重新创建它
我尝试了以下方法:
-
loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseMvc().RunProxy(new ProxyOptions { Scheme = "http", Host = "example", Port = "7777" }); -
在容器创建时设置 http_proxy 环境变量
export http_proxy=http://example:7777 -
使用 HttpClientHandler
var handler = new HttpClientHandler { Proxy = new WebProxy("http://example:777) }; var client = new HttpClient(handler); etc....
谁能想到其他方法来设置代理?或有关如何调试的任何建议?
【问题讨论】: