Operating System & Version
Linux
cPanel & WHM Version
102.0 (build 31)
Mar 28, 2023
15
1
3
Canada
cPanel Access Level
Root Administrator
For some reason this makes the main domain point to the port as well.

For clarify we have a domain and subdomain on the same account. I am trying to make a specific port go to subdomain.ca but when I do the following in the Pre Virtualhost include it makes the main domain point to it

"
ProxyPass /.well-known !
ProxyPass / http://www.subdomain.ca:1234/
ProxyPassReverse / http://www.subdomain.ca/
"
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,158
2,407
363
cPanel Access Level
Root Administrator
If they are both sharing the same vhost, that won't work. If the subdomain was created in cPanel, we should also have created a separate Apache vhost for the subdomain, which typically looks like this:

Code:
<VirtualHost 1.2.3.4:80>
  ServerName subdomain.domain.com
    ServerAlias www.subdomain.domain.com
  DocumentRoot /home/username/home/subdomaindirectory
  ServerAdmin [email protected]
Do you not see a separate vhost for your subdomain?
 
Mar 28, 2023
15
1
3
Canada
cPanel Access Level
Root Administrator
If they are both sharing the same vhost, that won't work. If the subdomain was created in cPanel, we should also have created a separate Apache vhost for the subdomain, which typically looks like this:

Code:
<VirtualHost 1.2.3.4:80>
  ServerName subdomain.domain.com
    ServerAlias www.subdomain.domain.com
  DocumentRoot /home/username/home/subdomaindirectory
  ServerAdmin [email protected]
Do you not see a separate vhost for your subdomain?
In in the include file? It is blank, there is nothing in there
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,158
2,407
363
cPanel Access Level
Root Administrator
You would just want to check the main Apache configuration to ensure a separate vhost exists. That's at /etc/apache2/conf/httpd.conf.

To only redirect the one specific subdomain, you would use the include file specific to that subdomain's vhost.
 
Mar 28, 2023
15
1
3
Canada
cPanel Access Level
Root Administrator
Wait nevermind I found the file. The subdomain does have the code you specified in the httpd.conf file for the subdomain. Now that I've confirmed there is a seperate vhost what do I need to do?

It states the location for an include file:
"
# To customize this VirtualHost use an include file at the following location
# Include "/etc/apache2/conf.d/userdata/std/2_4/[USERNAME]/[SUBDOMAIN]/*.conf"
"

So I would need to create a file at the specified location then add the the ProxyPassReverse?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,158
2,407
363
cPanel Access Level
Root Administrator
At the bottom of each vhost you'll see this message:

Code:
  # To customize this VirtualHost use an include file at the following location
  # Include "/etc/apache2/conf.d/userdata/std/2_4/username/sub.domain.com/*.conf"
so that is where you'd want to create your custom include file. You may not have anything deeper than /etc/apache2/conf.d/userdata/std/2_4/ so the other directories may need to be created before you can place your conf file there. You can name the conf file anything you wish - as long as it ends in .conf it can be read by the system.