Skip to main content

Cpanel x Apache Proxy Redirect x Docker

Comments

6 comments

  • cPAdminsMichael
    First - in general I'd recommend having dedicated servers for Docker/Kubernetes environment and not mixing that with cPanel :-) When that is said... how do you use mod_proxy, can you share the ProxyPass lines? Or maybe the whole .htaccess file would help.
    0
  • nunolopes
    Hi I use CPanel to be able to, easier, add new accounts pointing to docker applications, using WHM. So, if I want to add redmine, I just add a docker container with redmine, when using "docker run" I pass the database directives/configuration (username, pwd, etc...), map the directories I don't want inside the container (files for example) and that's it. On the other server it just works. My setup is like this: - on WHM add a new account; - on the registrar I point that domain/subdomain (the one used in the account's) to the server IP (I use the registrar's DNS configuration, not the server's); - after it is working, I add the docker container, exposing to the outside, a none used port (let's say 3000, 3001, etc...), but inside pointing to the correct port used by the application (on this redmine example it would be the port 3000); - then I add 2 files to the apache configuration, on these locations: /etc/apache2/conf.d/userdata/std/2_4///.conf /etc/apache2/conf.d/userdata/ssl/2_4///.conf Bellow, I substitute what is inside "<" and ">" with the correct values, for example: by redmine.mydomain.com and by 3000 Inside the 1st: Order deny,allow Allow from all ProxyPass / http://:/ ProxyPassReverse / http://:/ Order allow,deny Allow from all
    Inside the 2nd: ProxyPass / http://:/
    - Then, I run the script bellow to rebuild the apache configuration, acknowledging the new account's configuration files: /usr/local/cpanel/scripts/rebuildhttpdconf
    - And restart the apache server: /usr/local/cpanel/scripts/restartsrv_httpd
    On the old server, it just works. On the new server, as stated, if I go through apache I get a 502 bad gateway, but directly on http://: it works.
    0
  • cPAdminsMichael
    Hm... 502 Bad Gateway is usually because the proxy don't get anything back from the destination. Have you tried writing ip-address instead of hostname/domain? Having any enabled redirect rules? Forcing SSL? What does your Apache log files say?
    0
  • nunolopes
    Yes, tried with the server's public IP address and 127.0.0.1 and the docker container IP... none of them worked. The thing is that on the other server works. I thought maybe someone had had the same problem and knew what we needed to disable/enable to make it work on CPanel. I'll do some more digging on my side. Thanks anyway for your help.
    0
  • nunolopes
    SOLVED!! Found the problem: HG Firewall was blocking one of the ports needed. Added as inbound and outbound port, restarted the firewall and now working.
    0
  • cPanelLauren
    I'm glad to see you were able to resolve this issue and thank you for letting us know what the issue was!
    0

Please sign in to leave a comment.