Apache Reverse Proxy on a CentOS cPanel server

Setting up a reverse proxy or a regular CentOS server is quite straight forward, however when you have cPanel included in the equation, you need to be aware of a few things. That is why I've decided to write this short post here.
Here is what you need to do in order to get the reverse proxy working on a cPanel server:
1. Make sure that mod_proxy is installed:
httpd -M | grep -i 'proxy'
- if it is not installed you can install it via EasyApache
2. As this is a cPanel server you have to add the changes to a custom Vhost include at:
/usr/local/apache/conf/userdata/ssl/2_4/cPanel-Username/yourdomain.com/proxy_pass.conf
and
/usr/local/apache/conf/userdata/std/2_4/cPanel-Username/yourdomain.com/proxy_pass.conf
(change 'cPanel-User' with the actual cPanel username')
3. Then in order to enable this custom Vhost you have to run:
/scripts/ensure_vhost_includes --user=cPanel-User
(change 'cPanel-User' with the actual cPanel username')
4. After that you can then add the custom rules at the custom Vhost include files:
/usr/local/apache/conf/userdata/ssl/2_4/cPanel-Username/yourdomain.com/proxy_pass.conf
and
/usr/local/apache/conf/userdata/std/2_4/cPanel-Username/yourdomain.com/proxy_pass.conf
5. The rules that I used are quite simple, but you can adjust those if needed:
#Apache Reverse Proxy SSLProxyEngine on ProxyPass "/bobby" "https://bobbyiliev.com/" ProxyPassReverse "/bobby" "https://bobbyiliev.com/"
6. Then test for any syntax errors:
service httpd configtest
7. If you get 'Syntax OK' then it is alright to restart apache so it could pickup the new changes at the custom include.
This pretty much it. All of this is required because you would lose all of your changes if you add them directly to your main httpd conf file.
Hope that it helps.
Recent Posts

How DigitalOcean Simplifies Cloud Computing for Developers
2023-01-18 12:35:28
How to Get Current Route Name in Laravel
2020-11-08 08:57:11
How to check the logs of running and crashed pods in Kubernetes?
2020-10-28 09:01:44
Top 10 VScode Shortcuts For Mac and Windows to Help You be More Productive
2020-10-28 07:12:51