How to Setup Lightweight HTTP Proxy Server using Proxy.py on EC2

How to Setup Lightweight HTTP Proxy Server using Proxy.py on EC2

Takahiro Iwasa
(岩佐 孝浩)
Takahiro Iwasa (岩佐 孝浩)
1 min read
EC2 Proxy.py Python

Proxy.py, a lightweight HTTP proxy server, can be used on EC2 instances to access internal websites and APIs.

Installing Proxy.py

Install Proxy.py with the following command.

pip install proxy.py

Launching Proxy.py

Launch Proxy.py with the following command. After launching, you can view access logs in the terminal.

proxy --port 8080
pid:3330 [I] plugins.load:85 - Loaded plugin proxy.http.proxy.HttpProxyPlugin
pid:3330 [I] tcp.listen:82 - Listening on 127.0.0.1:8080
pid:3330 [I] pool.setup:108 - Started 1 acceptors in threaded mode
...

If you want to keep running the proxy after terminating the SSH session, use the following command instead.

nohup proxy --port 8080 > /dev/null &

Testing

Establish an SSH tunnel with the following command.

ssh -L 8080:localhost:8080 -i .ssh/YOUR_PRIVATE_KEY ec2-user@YOUR_HOST

Try accessing Google through the proxy server with the following command.

curl www.google.com -x http://localhost:8080
Takahiro Iwasa
(岩佐 孝浩)

Takahiro Iwasa (岩佐 孝浩)

Software Developer at iret, Inc.
Architecting and developing cloud native applications mainly with AWS. Japan AWS Top Engineers 2020-2023