Subscribe Quiz


by KAUSTUBH SHARMA on Feb. 16, 2018, 2:09 p.m. with 5796 views

What is an EC2 Proxy?

A proxy server is a computer that acts as an intermediate between you and the Internet. Similarly, An EC2 proxy server is an AWS EC2 instance that acts as an intermediate between you and the Internet.

Advantages of EC2 Proxy

  • Since your main server is not directly connected to the Internet. Thus, the EC2 proxy acts as a shield and takes blows for your place.
  • EC2 Proxy instances are also used to cache data for faster access.

Setting up a Proxy Server on AWS EC2

  • Now SSH  to newly created Ubuntu EC2 Instance.



  • .Open terminal & then the directory where you downloaded the .pem file while launching the EC2 Instance.
 chmod 400 my-key-pair.pem
    • chmod - To change access permissions, change mode. To read more about chmod & its numeric mode, please refer to the following article - CHMOD
    • my-key-pair.pem is the name of the .pem file which you downloaded while launching the EC2 Instance.


  •  Then, use the ssh command
ssh -i "my-key-pair.pem"


    • my-key-pair.pem is the name of the .pem file which you downloaded while launching the EC2 Instance.
    • ubuntu is the user name.
    •  is the DNS of your EC2 instance.


  • Install the update for Ubuntu with the below commands.
sudo apt update 
sudo apt upgrade


    • sudo apt update-  List all updates available with the permission of the root user(as we are using sudo). (Remember: It just listing the updates, not actually updating it.)
    • sudo apt upgrade- This command actually installs the updates.
  • We will use TinyProxy to set up our Ubuntu Server as the Proxy. By default, TinyProxy operates on Port 8888.
sudo apt install tinyproxy
  • Now modify the conf file of TinyProxy to allow only the IP address of your machine/s.
    Find Allow section of the conf file and add your device’s IP address so that it can be allowed to bypass the traffic.
    • Find the file directory.
    • Use the command- sudo vim /etc/tinyproxy/tinyproxy.conf  or sudo nano /etc/tinyproxy/tinyproxy.conf
    • Press “i” on the keyboard to be able to edit the entry.
    • Then press the “ESC” escape key to stop modification.
    • Use “:w” to write the change and “:q” to quit
      (NOTE: You can modify the port according to your need, but the default is 8888)
  • We need to restart the TinyProxy service so that the changes are reflected.
sudo /etc/init.d/tinyproxy restart
  • The last step would be modifying the inbound rules of the security group of our EC2 Instance such that only the trusted machines are able to access the proxy server which we created.


  • Now just configure this proxy where ever you want with the Public IP address of the Instance along with port 8888 or whatever port you defined in the "tinyproxy.conf" file.

Additionally, you can associate this Instance with an Elastic IP address. So, that Public IP doesn't change even if our EC2 instance got to stop/start again & again. As public IP changes, when we stop/start the EC2 instances.


Using a proxy on Amazon EC2 instances

If you want to configure a proxy on an Amazon EC2 instance launched with an attached IAM role, ensure that you exempt the address used to access the instance metadata. To do this, set the NO_PROXY environment variable to the IP address of the instance metadata service, NOTE: - This address does not vary.

Linux or macOS

$ export NO_PROXY=


C:\> setx NO_PROXY

Learn more this through Video on -YouTube