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

Conclusion

I find Proxy.py to be very handy when the situation does not call for setting up Nginx.

I hope you will find this post useful.

Takahiro Iwasa

Takahiro Iwasa

Software Developer at KAKEHASHI Inc.
Involved in the requirements definition, design, and development of cloud-native applications using AWS. Now, building a new prescription data collection platform at KAKEHASHI Inc. Japan AWS Top Engineers 2020-2023.