First of all thanks for the help, I'm trying to fix this problem for days
I know that is possible to route outbound traffic from a DigitalOcean droplet through its floating IP (a publicly-accessible static IP address that you can assign to a Droplet).
So, my droplet have 2 ip (regular and a floating ip) As suggested in this link https://www.digitalocean.com/community/questions/send-outbound-traffic-over-floating-ip, I found my droplet's "anchor IP" with
ip addr show eth0
I would like to make requests with python, using my IP as a proxy. I can do this? For example, something as:
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 is my anchor ip
YY -> What port I have to use?
I have to add some rules to my Firewall (UFW) ?
Thanks in advance
First, Assign a floating IP on your Droplet.
Install squid
apt-get update apt-get install -y squid
Configure squid proxy: search on Google how to do basic configuration.
Find your droplet's "anchor IP" with
ip addr show eth0
This is an example of output:
inet "YOUR_IP1"/20 brd 123.456.789.012 scope global eth0
valid_lft forever preferred_lft forever
inet "YOUR_IP2"/16 brd 12.34.567.890 scope global eth0
valid_lft forever preferred_lft forever
Add these lines to /etc/squid/squid.conf:
acl myip_1 myip YOUR_IP1
tcp_outgoing_address YOUR_IP1 myip_1
acl myip_2 myip 10.17.0.5
tcp_outgoing_address 10.17.0.5 myip_2
and
import requests
proxies = {
'http': 'http://PUBLIC_IP:PORT',
'https': 'http://PUBLIC_IP:PORT',
}
# 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....')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With