skip to Main Content

I have an webpage(UI) which is hosted in EC2 instance ( In private subnet) and accessible only in RDP (created in the same VPC) using IP address of the instance and port no (IP address:port no.). Now I want to make the webpage public ( anyone can access it )… without opening the ports to public….
Any method to do it…pls help.
For backend services am using network load balancer and API gateway for accessing it locally

2

Answers


  1. To access a user interface (UI) deployed on a private EC2 instance from your local machine, you can set up a secure remote connection using SSH tunneling. Here’s a general outline of the steps involved:

    1. Establish an SSH connection to the EC2 instance: Use SSH to connect to the EC2 instance hosting the UI. If you’re using a Linux or macOS terminal, you can use the following command:
    **ssh -i <path-to-private-key> <username>@<EC2-instance-IP>**
    

    Replace <path-to-private-key> with the path to your private key file, <username> with the appropriate username, and <EC2-instance-IP> with the IP address or hostname of your EC2 instance.

    1. Configure SSH tunneling: Once you’re connected to the EC2 instance, you can set up SSH tunneling to forward the UI’s port to your local machine. For example, if the UI is running on port 8080, you can use the following command on the EC2 instance:
    **ssh -L 8080:localhost:8080 -N -f -i <path-to-private-key> <username>@<EC2-instance-IP>**
    

    This command forwards the local port 8080 to the EC2 instance’s port 8080.

    1. Access the UI from your local machine: With the SSH tunnel established, you can now access the UI on your local machine’s web browser. Open your browser and navigate to http://localhost:8080. The request will be forwarded through the SSH tunnel to the EC2 instance, allowing you to view the UI.

    Note: Make sure the UI service is running on the specified port (8080 in the example) on the EC2 instance, and any necessary firewall or security group rules are configured to allow inbound connections to that port.

    Remember to replace <path-to-private-key>, <username>, <EC2-instance-IP>, and the port number (8080 in the example) with the appropriate values based on your setup.

    Additionally, if your EC2 instance is located in a private subnet and does not have direct internet access, you may need to set up a bastion host or VPN connection to establish a secure connection to the private network before following the steps above.

    Login or Signup to reply.
  2. You need an application load balancer here. Create an application load balancer in your public subnet and route traffic from the application load balancer to your web UI (EC2 instance in a private subnet). You will also need to point your DNS to the load balancer’s FQDN.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search