Docker Containers, Apache Vhost, Proxy SubDomains
I haven't used cPanel in a LONG time. The cPanel documentation I've been reading on the "WHM" variant is not matching up with the WHM server I am trying to get working.
Our JS dev has created a few Docker containers on the server, each with their own ports they are listening on. I need to connect them to the server so WordPress can talk to them.
I tried setting up the subdomains through the documentation, but WHM had nothing at all listed in the "subdomain" section. I found the option in the DNS section and there I created two CNAME's (api-docs.domain.tld and docs.domain.tld). I'm not sure how I go about adding these subdomains to the SSL cert (I'm used to using Let's Encrypt).
Next, he requested "proxying incoming requests from Apache HTTPS port 443 to respective application parts based either on subdomain mapping or on path mapping".
I added this code into the post_virtualhost_2 section through the WHM panel:
However, nothing loads. Any help or guidance in the right direction would be greatly appreciated.
ServerName docs.domain.tld
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:5000/"
ProxyPassReverse "/" "http://127.0.0.1:5000/"
ServerName api-docs.domain.tld
ProxyPreserveHost On
ProxyPass "/api/graphql" "http://127.0.0.1:8080/api/graphql"
ProxyPassReverse "/api/graphql" ""http://127.0.0.1:8080/api/graphql"
However, nothing loads. Any help or guidance in the right direction would be greatly appreciated.
-
Hey there! I think the first thing we'll need to know is why there is a difference in the WHM versions. Can you run "/usr/local/cpanel/cpanel -V" or check the cPanel & WHM version in the top-right corner of the WHM interface to get us the version details? 0 -
Hey there! I think the first thing we'll need to know is why there is a difference in the WHM versions. Can you run "/usr/local/cpanel/cpanel -V" or check the cPanel & WHM version in the top-right corner of the WHM interface to get us the version details?
92.0 (build 9)0 -
Thanks for the details. That is the current stable release so I wouldn't expect that to be different than the documentation. Can you let me know what pages you're referencing and where the confusion starts so I can get you better details? 0 -
To start, I'm having to learn WHM's ways of handling the processes of creating a config through a UI, I'm used to the cmd line for doing this. Starting this whole thing over: - Can you point me in the direction of using WHM's panel to create a few subdomains (I'm guessing the DNS zone -> add CNAMEs). Also, I created DNS zones instead of editing the main domain's CNAME, so if you know how to remedy: "No vhosts config data for user "XXXX" at /usr/local/cpanel/Cpanel/Config/WebVhosts.pm line 86." - Can you point me in the direction of the virtualhost config directories that will allow for use of the subdomains as a proxy to docker containers? 0 -
Great - those questions actually help clear things up on my end too :D In order to create a subdomain you'd actually want to be logged into the cPanel for the account and not the WHM interface. You can get to this area from WHM >> List Accounts and then click the cPanel logo next to the domain you want to work with. You'll likely want to remove any custom DNS records you've created at this point as they'll get recreated when you set up the subdomain through cPanel. Once you're inside cPanel you'll see the "Subdomains" icon and that's where you'll get that created. Performing that work in the interface inside cPanel will also create the vhost and resolve that issue you're seeing. Once that is created you'll have the correct files setup in Apache and DNS for the subdomain to work properly. Instead of editing the configuration directly, which cPanel will overwrite, you'll want to use include files as outlined here: as that will let you modify the specific subdomain on the system. Can you work through that and let me know if that works how you expect? 0 -
Was unable to delete the old "subdomains" I accidentally created through WHM's DNS Zone, and cPanel warned me "A DNS entry for the domain 'docs.domain.tld' already exists. at /usr/local/cpanel/Cpanel/Admin/Modules/Cpanel/subdomain.pm line 176." For now I created two new subdomains: d.domain.tld and app-d.domain.tld. I created a .conf file in the ssl directory for d.domain.tld: "/etc/apache2/conf.d/userdata/ssl/2_4/domainuser/d.domain.tld/d.domain.tld.conf" and nothing loads. I tried a default check on the url with a basic index.html to test and nothing there either. 0 -
Thanks for the additional details. The only thing we'd be able to confirm on our end is that the include is valid and being read properly, which it sounds like it is. The issue here sounds like a problem with the ports and proxying, which isn't something that is included in cPanel by default. If you'd like to open a ticket with our team we could do some additional testing on our end with this, but I can't guarantee we'll be able to get things working properly even if we have access to the system as this isn't a standard configuration option with cPanel tools. 0 -
No worry, I will figure it out. I am trying to speed run it and that's never a good thing. 0 -
I got it working, all that was needed was this: Cpanel ReverseProxy Traffic to Docker Container " ServerOK I had issues due to our weird DNS config and not cPanel and WHM, apologies. Sorted that out and all is good (plus I learned a lot about cPanel). 0
Please sign in to leave a comment.
Comments
9 comments