Use Apache as a Reverse Proxy to another Service
If you've got another web application running on your server, but still want it served up on port 80 or 443 you can use Apache's mod_proxy
to forward traffic from Apache to your application.
An example would be if your web application is running on http://localhost:8080
you can use Apache to redirect traffic from http://service.yourdomain.com
to that web app. Simply create a new configuration file for Apache under /etc/httpd/conf.d
with the following:
# Put this after the other LoadModule directives
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
# Put this with your other VirtualHosts, or at the bottom of the file
NameVirtualHost *
<VirtualHost *:80>
ServerName service.yourdomain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Restart Apache and you should be good to go.
systemctl restart httpd