Quick Tip: Use Apache as a proxy server to access internal IPs from an external machine

Nick Chase - May 7, 2019 - ,

Sometimes, when you’re using a cloud server, you find yourself in a situation where you don’t have a GUI, but you still want to access a web server running on a local IP address. For example, if you install MCP using the Model Designer, what you get back will be an instance that includes DriveTrain running on a local IP address.  To solve this problem, we can use Apache as a proxy server to access that local IP address via an external IP address to that VM.

Obviously running an Apache proxy to another server isn’t something you will do lightly, and you may not do it at all for a production system; To use Apache as proxy on an unsecured server is inviting trouble, so make sure to do your security due diligence! But Just for testing, this can be a handy tip.

Fortunately it’s a straightforward process Here are the steps to use Apache as proxy:

  1. Start by installing apache2. On Ubuntu, this is just a matter of calling the package manager:
    sudo apt-get install apache2
  2. Enable the various modules needed to run an Apache proxy server. You can do that with the a2enmod tool:
    a2enmod proxy
    a2enmod proxy_http
    a2enmod proxy_ajp
    a2enmod rewrite
    a2enmod deflate
    a2enmod headers
    a2enmod proxy_balancer
    a2enmod proxy_connect
    a2enmod proxy_html
  3. Access the Apache configuration  and add the following content to the /etc/apache2/sites-available/000-default.conf file to read:
    
        ProxyPreserveHost On
    
        # Servers to proxy the connection, or;
        # List of application servers:
        # Usage:
        # ProxyPass / http://[IP Addr.]:[port]/
        # ProxyPassReverse / http://[IP Addr.]:[port]/
    
        # Example: 
        ProxyPass / http://10.10.0.15:8081/
        ProxyPassReverse / http://10.10.0.15:8081/
    
        ServerName localhost
    

    Obviously, make sure to use your own target URLs. Also, set the Apache proxy to port 80 (or whatever port you choose — in this case, 8081).

  4. After configuring and setting the required parameters, restart the apache2 service to finally use Apache as proxy:
    service apache2 restart

At this point you can access the internal IP address (or whatever address you chose) from the main URL served by Apache. For more information, be sure to check Apache documentation online.  

banner-img
From Virtualization to Containerization
Learn how to move from monolithic to microservices in this free eBook
Download Now
Radio Cloud Native – Week of May 11th, 2022

Every Wednesday, Nick Chase and Eric Gregory from Mirantis go over the week’s cloud native and industry news. This week they discussed: Docker Extensions Artificial Intelligence shows signs that it's reaching the common person Google Cloud TPU VMs reach general availability Google buys MobileX, folds into Google Cloud NIST changes Palantir is back, and it's got a Blanket Purchase Agreement at the Department of Health and Human …

Radio Cloud Native – Week of May 11th, 2022
Where do Ubuntu 20.04, OpenSearch, Tungsten Fabric, and more all come together? In the latest Mirantis Container Cloud releases!

In the last several weeks we have released two updates to Mirantis Container Cloud - versions 2.16 and 2.17, which bring a number of important changes and enhancements. These are focused on both keeping key components up to date to provide the latest functionality and security fixes, and also delivering new functionalities for our customers to take advantage of in …

Where do Ubuntu 20.04, OpenSearch, Tungsten Fabric, and more all come together? In the latest Mirantis Container Cloud releases!
Monitoring Kubernetes costs using Kubecost and Mirantis Kubernetes Engine [Transcript]

Cloud environments & Kubernetes are becoming more and more expensive to operate and manage. In this demo-rich workshop, Mirantis and Kubecost demonstrate how to deploy Kubecost as a Helm chart on top of Mirantis Kubernetes Engine. Lens users will be able to visualize their Kubernetes spend directly in the Lens desktop application, allowing users to view spend and costs efficiently …

Monitoring Kubernetes costs using Kubecost and Mirantis Kubernetes Engine [Transcript]
Technical training
Learn Kubernetes & OpenStack from Deployment Experts
Prep for certification!
View schedule
LIVE WEBINAR
Manage your cloud-native container environment with Mirantis Container Cloud

Wednesday, January 5 at 10:00 am PST
SAVE SEAT
LIVE WEBINAR
Istio in the Enterprise: Security & Scale Out Challenges for Microservices in k8s

Presented with Tetrate
SAVE SEAT