Accessing Isolated Networks via AWS Elastic IP and Proxy
When working with enterprise APIs or isolated client networks, it’s common to be asked to access their environment from a known static IP. If your development environment is dynamic or cloud-based, AWS provides an elegant solution using Elastic IPs and proxy servers.
๐ฏ Problem: Static IP Required for API or Network Access
Many enterprise systems and secure networks restrict access to a fixed set of whitelisted IP addresses. If you’re working from a laptop, development environment, or cloud VPC without a static public IP, your requests may be blocked or rejected for security reasons.
โ Common Scenarios:
- API firewalls requiring static IP
- Private VPC-to-VPC access between organizations
- Testing from different geographic regions via a whitelisted IP
๐งฉ Solution 1: Static IP from ISP or VPN
If your internet provider offers a static IP, you can request access using that. However:
- โ Simple and local
- โ Not portable โ tied to location or hardware
- โ Changing locations breaks access
๐ฉ๏ธ Solution 2: Use AWS Elastic IP + Proxy
AWS Elastic IP is a fixed, public IPv4 address you can attach to EC2. By setting up a proxy server on the EC2 instance, you can route any request (from browser, backend, or script) through this IP.
โ Advantages:
- ๐ฏ Globally accessible
- ๐ Easily secured via AWS Security Groups
- ๐ ๏ธ Fully scriptable and scalable
๐ง Step-by-Step: Setup HTTP Proxy with Squid on EC2
- Launch EC2:
- Use Ubuntu 20.04 or 22.04
- Instance type:
t2.micro
(Free Tier eligible) - Allow SSH (port 22) and custom TCP port (3128)
- Allocate and associate an Elastic IP:
- In the AWS EC2 dashboard โ Elastic IPs โ Allocate
- Associate this IP with your running EC2 instance
- Install Squid:
sudo apt update && sudo apt install squid -y
- Configure Proxy Access:
Edit the configuration file:
Add or modify these lines:sudo nano /etc/squid/squid.conf
http_port 3128 # Allow all (or restrict to your IP) acl allowed_ips src 0.0.0.0/0 http_access allow allowed_ips http_access deny all
Note: Replace
0.0.0.0/0
with your IP range for added security (e.g.,203.0.113.0/24
orYOUR_IP/32
). - Restart the Squid service:
sudo systemctl restart squid
Optional: check status
sudo systemctl status squid
- Open port 3128 in your EC2 Security Group:
- Go to EC2 โ Security Groups โ Inbound rules โ Add Rule
- Type: Custom TCP
- Port:
3128
- Source:
Your IP
or0.0.0.0/0
(if testing)
- โ
Share the Elastic IP with Your Client
Provide the client with your Elastic IP address to allow in their firewall or API gateway. For example:
Static IP: 54.123.45.67
๐ How to Restrict Proxy Access
- ๐ก๏ธ Use Squidโs
acl allowed_ips
to allow only specific IPs - ๐ Secure EC2’s Security Group to your developer IPs only
๐ How to Use the Proxy (Elastic IP) with Real API Calls
Once your proxy is live (e.g., http://54.123.45.67:3128
), hereโs how to route your traffic through it from different environments.
๐งช 1. curl
curl -x http://54.123.45.67:3128 https://jsonplaceholder.typicode.com/posts/1
๐ 2. Google Chrome (System Proxy)
- Go to
chrome://settings/system
- Click โOpen your computerโs proxy settingsโ
- Set:
- HTTP Proxy: 54.123.45.67
- Port: 3128
- Save and test by visiting: https://jsonplaceholder.typicode.com/posts/1
๐ฌ 3. Postman
- Go to Settings โ Proxy
- Set:
- Proxy Type: HTTP
- Server: 54.123.45.67
- Port: 3128
- Enable global proxy or per-request proxy
- Make a GET request to
https://jsonplaceholder.typicode.com/posts/1
๐ 4. Ruby on Rails (Faraday Example)
conn = Faraday.new(
url: 'https://jsonplaceholder.typicode.com',
proxy: 'http://54.123.45.67:3128'
)
response = conn.get('/posts/1')
puts response.body
๐น๏ธ 5. WebGL / Browser Fetch (via system proxy)
Browser apps (including WebGL) will automatically use system-level proxy settings.
Follow the Chrome system proxy setup above, then run:
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then(res => res.json())
.then(console.log)
๐ง 6. Node.js (with axios + https-proxy-agent)
const axios = require('axios');
const HttpsProxyAgent = require('https-proxy-agent');
const proxyAgent = new HttpsProxyAgent('http://54.123.45.67:3128');
axios.get('https://jsonplaceholder.typicode.com/posts/1', {
httpsAgent: proxyAgent
}).then(res => console.log(res.data))
.catch(err => console.error(err));
โ๏ธ 7. React (via Node backend or dev proxy)
React apps can’t directly configure HTTP proxies in browser JS. You should:
- Use a proxy-aware backend (e.g., Node, Rails)
- Or run a local proxy via
http-proxy-middleware
during development
React Dev Proxy (Optional) โ in package.json
:
{
"proxy": "http://54.123.45.67:3128"
}
โ ๏ธ This only works for same-origin development APIs. Better to use a backend like Node or Rails to proxy requests through EC2.
โ Why Use a Proxy?
A proxy server acts as an intermediary between your app and the target API. When routed through EC2, it makes requests appear to come from the Elastic IP.
โ Use Cases:
- Bypass network restrictions (ethically)
- Route all outbound API requests from a known IP
- Debug and log requests from multiple sources
โ ๏ธ Proxy Risks:
- Open proxies may be abused if not secured
- Must monitor usage to prevent misuse
๐ Alternatives to Proxy Access
Method | Pros | Cons |
---|---|---|
VPN Tunnel | Secure, bidirectional | Complex setup, requires client VPN support |
VPC Peering | Low latency, internal IPs | Only for AWS-to-AWS, hard to manage across orgs |
PrivateLink / Transit Gateway | Highly secure AWS-to-AWS access | Costly, complex to set up |
Elastic IP + Proxy (Recommended) | Easy, works globally, scalable | Requires proxy config and IP restrictions |
๐ Conclusion
If your client requires access from a fixed IP address, using an AWS EC2 + Elastic IP + HTTP Proxy is a clean, scalable, and secure solution โ especially when combined with IP allowlisting and AWS security groups.
Learn more aboutย Cloud
https://shorturl.fm/N6nl1
https://shorturl.fm/m8ueY
https://shorturl.fm/YvSxU
https://shorturl.fm/XIZGD
https://shorturl.fm/j3kEj
https://shorturl.fm/YvSxU
https://shorturl.fm/6539m
https://shorturl.fm/a0B2m
https://shorturl.fm/68Y8V
https://shorturl.fm/a0B2m
https://shorturl.fm/bODKa
https://shorturl.fm/TbTre
https://shorturl.fm/A5ni8
https://shorturl.fm/A5ni8
https://shorturl.fm/eAlmd
https://shorturl.fm/JtG9d