Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a website that is meant to be using SSL, however there are two entries in Cpanel's httpd.conf which seem to be causing an issue. When I visit just www.website.com I require it to go to https://www.website.com. However I have to write the https:// directly for the site to work. The secure site also has a different IP.

I am not meant to edit the httpd.conf directly either and am unsure as to how to change the following directives:

<VirtualHost 1.1.1.1:80>
    ServerName website.com
    ServerAlias www.website.com
    DocumentRoot /home/websitec/public_html
    ServerAdmin webmaster@website.com
    ## User websitec # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup websitec websitec
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
           SuexecUserGroup websitec websitec
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
       RUidGid websitec websitec
    </IfModule>
    CustomLog /usr/local/apache/domlogs/website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    CustomLog /usr/local/apache/domlogs/website.com combined
    ScriptAlias /cgi-bin/ /home/websitec/public_html/cgi-bin/
</VirtualHost>
<VirtualHost 2.2.2.2:443>
    ServerName website.com
    ServerAlias www.website.com
    DocumentRoot /home/websitec/public_html
    ServerAdmin webmaster@website.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/website.com combined
    CustomLog /usr/local/apache/domlogs/website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User websitec # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup websitec websitec
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup websitec websitec
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
        RUidGid websitec websitec
    </IfModule>
    ScriptAlias /cgi-bin/ /home/websitec/public_html/cgi-bin/
    SSLEngine on

    SSLCertificateFile /etc/ssl/certs/www.website.com.crt
    SSLCertificateKeyFile /etc/ssl/private/www.website.com.key
        SSLCACertificateFile /etc/ssl/certs/www.website.com.cabundle
    CustomLog /usr/local/apache/domlogs/website.com-ssl_log combined
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    <Directory "/home/websitec/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/websitec/website.com/*.conf"

</VirtualHost>

As you can see there is obviously the unsecure directive before the secure one. And this is probably the issue, however if I try to change the IP for the site in WHM I get an error saying that the IP (2.2.2.2) is already in use. Which it is I guess.

Any help is appreciated.

share|improve this question
add comment

1 Answer

It is unclear in your question if you are supposed to have two different entries for your same site using different IP address. I am not aware that something like this is even possible with cPanel, let alone a standalone server (unless you are running some funky non-standard setup). To me it sounds like a bug/incorrect setup. I would recommend rebuilding the httpd.conf file.

  1. Backup your httpd.conf file just incase: cp httpd.conf httpd.conf.backup
  2. Rebuild httpd.conf file by running /usr/local/cpanel/bin/build_apache_conf
  3. Test to see if any errors are present in your httpd.conf file service httpd -t or service httpd config-test (depending on which version of Apache you are running).

If in fact I was correct that the two entires should not be present, then this should have fixed it. Now lets move on to installing the SSL certificate.

Basics

  1. SSL needs a dedicated IP address. You can modify the site to have a dedicated IP address by WHM: Main >> Account Functions >> Change Site's IP Address
  2. Generate SSL certificate for your site by WHM: Main >> SSL/TLS >> Generate a SSL Certificate and Signing Request
    1. Send the signing request to your SSL company
  3. Install the provided SSL certificate from your SSL company via WHM: Main >> SSL/TLS >> Install a SSL Certificate and Setup the Domain

If all is good, your SSL certificate should be installed and both http://www.website.com/ and https://www.website.com/ should be working fine. If you would like to setup redirection, this can be done within cPanel for that domain.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.