top of page

How to setup reverse proxy on apache2

Writer's picture: Rahul RRahul R

To set up a reverse proxy to a local installation using Apache2, you need to configure the Apache Virtual Hosts to forward requests to your local server. Here's a step-by-step guide:


Enable Proxy Modules:


Before setting up the reverse proxy, you need to make sure the proxy modules are enabled in Apache. You can enable them using the following commands:


sudo a2enmod proxy
sudo a2enmod proxy_http

Create a Virtual Host Configuration:


Create a new Virtual Host configuration file or modify an existing one. You can typically find Virtual Host configuration files in the /etc/apache2/sites-available/ directory.


<VirtualHost *:80>
    ServerName yourdomain.com
    ProxyRequests Off
    ProxyPass / http://localhost:YOUR_LOCAL_PORT/
    ProxyPassReverse / http://localhost:YOUR_LOCAL_PORT/
</VirtualHost>

Replace yourdomain.com with your actual domain or server IP address. Replace YOUR_LOCAL_PORT with the port number of your local server where the application is running.


Enable the Virtual Host:


Once you have created or modified the Virtual Host configuration, enable it by creating a symbolic link to the sites-enabled directory:


sudo a2ensite your_virtual_host_config_file.conf

Replace your_virtual_host_config_file.conf with the name of your Virtual Host configuration file.


Restart Apache:


After enabling the Virtual Host, restart Apache to apply the changes:


sudo service apache2 restart

Test the Setup:


Visit your domain or server IP address in a web browser, and Apache will forward requests to your local server. Make sure your local server is running and accessible from the Apache server.

14 views0 comments

Recent Posts

See All

How to Attach S3 to your Django Project

Install Required Packages: Install django-storages package, which provides support for various storage backends including Amazon S3. You...

Commentaires


bottom of page