Cpanel ReverseProxy Traffic to Docker Container

On a cpanel server, i need to run a web application using docker container.

Application running side docker container listening on port 8000 on localhost.

For a web site to serve traffic from this docker container, we can use Apache mod_proxy, this is enabled by default on cpanel servers.

https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

You can verify it at

Apache mod_proxy

For the site, you need to create reverse proxy, create a folder.

NOTE: Replace CPANEL_USER and DOMAIN with your actual cpanel user name and domain name. You can find/verify this path by looking virtual host entry for your domain name in /etc/apache2/conf/httpd.conf file. By default this “Include” line will be commented. Once you put a file and rebuildhttpdconf, this line get uncommented.

Now create a file

Add following.

Now rebuild Apache config.

Now if you check Apache config file (/etc/apache2/conf/httpd.conf), you will see included in Apache virtual host entry.

Restart Apache

Now if you visit the site, you will see the web application running on http://localhost:8000/

See Reverse proxy, Cpanel Server, Apache

Need help with Linux Server or WordPress? We can help!

One thought on “Cpanel ReverseProxy Traffic to Docker Container

  • Hi

    I followed this tutorial, but I couldn’t get it to work. If I remove the port:

    ProxyPass “/” “http:///”
    ProxyPassReverse “/” “http:///”

    …it works, but points to the www root on this CPanel account!

    But, if I define a port, it doesn’t work, I get an error 502 (bad gateway).

    I have a CPanel CentOS7 box, CPanel updated to the most recent version, with mod_proxy enabled, installed Docker, I am running a docker image with Redmine, this image is accessible on the internet if I go to http://mydomain.com:3000/, but mod_proxy doesn’t redirect the requests from mydomain.com:80 to mydomain.com:3000, even after I followed every step of your tutorial.

    I tried to do the redirect with the internal docker IP and with the domain, but it doesn’t seem to work either way.

    Is there anything else I should do to make this work?

    Thanks in advance for any help you can provide,
    Best,
    Nuno Lopes

Leave a Reply

Your email address will not be published. Required fields are marked *