To redirect to localhost on a specific port, such as 14788, follow these steps to configure your Apache server.
Ensure Apache is installed on your server. If it's not installed, you can install it using your operating system's package manager. For example, on Ubuntu, you can use:
sudo apt-get update
sudo apt-get install apache2
You need to enable the mod_proxy
and mod_proxy_http
modules, necessary for setting up a reverse proxy. Enable these modules by running:
sudo a2enmod proxy
sudo a2enmod proxy_http
Create a new virtual host file or modify an existing one in the /etc/apache2/sites-available/
directory:
sudo vim /etc/apache2/sites-available/reverse-proxy.conf
ServerName
as needed:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location />
ProxyPass http://localhost:14788/
ProxyPassReverse http://localhost:14788/
</Location>
</VirtualHost>
Enable the new virtual host configuration by running:
sudo a2ensite reverse-proxy.conf
Restart the Apache server to apply your configuration changes:
sudo systemctl restart apache2
Test the setup by accessing http://example.com
(or your server's public IP if you don't have a domain configured). It should proxy the requests to http://localhost:14788
.
Ensure that the application running on port 14788 is configured to accept connections from Apache, possibly involving CORS or similar settings depending on your application.
If you run into any issues, checking the Apache error logs (/var/log/apache2/error.log
) can provide more insight into what might be going wrong.