To serve the content from localhost:3001
directly when you access http://localhost
, you need to configure Apache to act as a reverse proxy. This setup will forward requests from http://localhost
to http://localhost:3001
without the user needing to manually enter the port.
Here's how you can set it up:
Ensure the Necessary Modules Are Enabled:
You need the mod_proxy
and mod_proxy_http
modules enabled in your Apache configuration. In the Apache configuration file (httpd.conf
), ensure the following lines are uncommented:
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so
Add the Reverse Proxy Configuration:
Add a VirtualHost entry to set up the reverse proxy.
Here's the updated Apache configuration:
<VirtualHost *:80> ServerName localhost # Proxy settings ProxyPreserveHost On ProxyPass / http://localhost:3001/ ProxyPassReverse / http://localhost:3001/ </VirtualHost> <VirtualHost *:80> DocumentRoot C:\laragon\www\projects\file_manager\server\public ServerName admin.promo.local </VirtualHost>
Steps to Implement:
Locate the Configuration File:
For Laragon, you might find the configuration file at C:\laragon\bin\apache\httpd-2.4.35\conf\httpd.conf
or a similar path.
Edit the Configuration:
- Open the configuration file with a text editor.
- Add the VirtualHost entry for
localhost
with the proxy settings as shown above. - Ensure the necessary modules are loaded by checking for the
LoadModule
lines mentioned above.
Save and Restart Apache:
- Save the changes to the configuration file.
- Restart Apache to apply the changes. This can be done through the Laragon control panel or via command line.