Background:
We have been trying to get a wildcard SSL working on multiple sub domains on a single dedicated address.. We have
two sub domains next.my-personal-website.com and blog.my-personal-website.com
Part of our strategy has been to edit the httpd.conf and add the NameVirtualHost xx.xx.144.72:443 directive and the virtualhost entries for port 443 for the subdomains there.
This works good if we just edit the httpd.conf, add the entries, save it and restart the apache.
The problem:
But if we add a new sub domain from cpanel or we run the
# /usr/local/cpanel/bin/apache_conf_distiller --update
# /scripts/rebuildhttpdconf
the virtualhost entries that we added manually are no more there in the newly generated httpd.conf file. Only the virtualhost entry for the main domain for port 443 that was there before we made edits to the httpd.conf is there(assuming we are not discussing virtualhost entries for port 80).
I understand we need to put the new virtualhost entries in some include files as mentioned here in the cpanel documentation. But am not sure where to.
So the question would be where do I put the NameVirtualHost xx.xx.144.72:443 directive and the
two virtualhost directive for port 443, so that they are not overwritten when httpd.conf is rebuilt/regenerated later.
Virtualhost entries:
The
two virtualhost entries for the subdomains are:
<VirtualHost xx.xx.144.72:443>
ServerName next.my-personal-website.com
ServerAlias www.next.my-personal-website.com
DocumentRoot /home/myguardi/public_html/next.my-personal-website.com
ServerAdmin
[email protected]
UseCanonicalName On
CustomLog /usr/local/apache/domlogs/next.my-personal-website.com combined
CustomLog /usr/local/apache/domlogs/next.my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User myguardi # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup myguardi myguardi
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup myguardi myguardi
</IfModule>
ScriptAlias /cgi-bin/ /home/myguardi/public_html/next.my-personal-website.com/cgi-bin/
SSLEngine on
SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
CustomLog /usr/local/apache/domlogs/next.my-personal-website.com-ssl_log combined
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
<Directory "/home/myguardi/public_html/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
and
<VirtualHost xx.xx.144.72:443>
ServerName blog.my-personal-website.com
ServerAlias www.blog.my-personal-website.com
DocumentRoot /home/myguardi/public_html/blog.my-personal-website.com
ServerAdmin
[email protected]
UseCanonicalName On
CustomLog /usr/local/apache/domlogs/blog.my-personal-website.com combined
CustomLog /usr/local/apache/domlogs/blog.my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User myguardi # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup myguardi myguardi
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup myguardi myguardi
</IfModule>
ScriptAlias /cgi-bin/ /home/myguardi/public_html/blog.my-personal-website.com/cgi-bin/
SSLEngine on
SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
CustomLog /usr/local/apache/domlogs/blog.my-personal-website.com-ssl_log combined
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
<Directory "/home/myguardi/public_html/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
and the automatically generated virtualhost entry for the main domain for port 443 is
<VirtualHost xx.xx.144.72:443>
ServerName my-personal-website.com
ServerAlias www.my-personal-website.com
DocumentRoot /home/myguardi/public_html
ServerAdmin
[email protected]
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/my-personal-website.com combined
CustomLog /usr/local/apache/domlogs/my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User myguardi # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup myguardi myguardi
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup myguardi myguardi
</IfModule>
ScriptAlias /cgi-bin/ /home/myguardi/public_html/cgi-bin/
SSLEngine on
SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
CustomLog /usr/local/apache/domlogs/my-personal-website.com-ssl_log combined
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
<Directory "/home/myguardi/public_html/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/ssl/2/myguardi/my-personal-website.com/*.conf"
I really appreciate if somebody can tell me how to proceed on this. Thank you.
Update: Include directives present are:
`Include "/usr/local/apache/conf/includes/pre_main_global.conf"
Include "/usr/local/apache/conf/includes/pre_main_2.conf"
Include "/usr/local/apache/conf/php.conf"
Include "/usr/local/apache/conf/includes/errordocument.conf"
Include "/usr/local/apache/conf/modsec2.conf"
Include "/usr/local/apache/conf/includes/pre_virtualhost_global.conf"
Include "/usr/local/apache/conf/includes/pre_virtualhost_2.conf" `
These are the entries that are generated before any virtualhost entry is defined. Towards the end of the httpd.conf file , the following
two entries are added
Include "/usr/local/apache/conf/includes/post_virtualhost_global.conf"
Include "/usr/local/apache/conf/includes/post_virtualhost_2.conf"
The older httpd.conf file before we added the virtualhost entries for sub domains for port 443 can be viewed here