【发布时间】:2018-09-05 14:34:39
【问题描述】:
首先感谢您的帮助,我正在尝试解决这个问题好几天
我知道可以通过其浮动 IP(您可以分配给 Droplet 的可公开访问的静态 IP 地址)路由来自 DigitalOcean Droplet 的出站流量。
所以,我的 droplet 有 2 个 ip(常规和浮动 ip) 正如此链接https://www.digitalocean.com/community/questions/send-outbound-traffic-over-floating-ip 中所建议的那样,我发现我的 droplet 的“锚 IP”与
ip addr show eth0
我想使用我的 IP 作为代理使用 python 发出请求。我可以做这个?例如:
import requests
proxies = {
'http': 'http://XX.XX.XX.XX:YY',
'https': 'http://XX.XX.XX.XX:YY',
}
# Create the session and set the proxies.
s = requests.Session()
s.proxies = proxies
# Make the HTTP request through the session.
r = s.get('https://www....')
XX.XX.XX.XX是我的主播ip
YY -> 我必须使用什么端口?
我必须向我的防火墙 (UFW) 添加一些规则?
提前致谢
【问题讨论】:
-
请求的代理功能用于HTTP代理服务器。如果您希望流量通过机器上的特定接口进行路由,您应该使用操作系统中的路由功能(例如 Linux 中的
route)。
标签: python proxy python-requests firewall droplet