Setting up apache to view https pages

Posted on

Setting up apache to view https pages – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, ssl, https, , .

I am trying to set up a site using vmware workstation, ubuntu 11.10, and apache2. The site works fine but now the https pages are not showing up. For example if I try to go to https://www.mysite.com/checkout I just see the message

Not Found The requested URL /checkout/ was not found on this server.

I dont really know what I am doing and have tried a lot of things to get the ssl certificates in there right.

A few things I have in there, in my httpd.conf I just have :

ServerName localhost

In my ports.conf I have :

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443 http
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443 http
</IfModule>

In the /etc/apache2/sites-available/default-ssl :

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

     .... truncated

in the sites-available/default I have :

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        #DocumentRoot /home/magento/site/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
        #<Directory /home/magento/site/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all


        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>
<virtualhost *:443>
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/server.crt
        SSLCertificateKeyFile /etc/apache2/ssl/server.key
        ServerAdmin webmaster@localhost
  <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
        #<Directory /home/magento/site/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all


        </Directory>

</virtualhost>

I also have in sites-availabe a file setup for my site url, www.mysite.com so in /etc/apache2/sites-available/mysite.com

<VirtualHost *:80>
        ServerName mysite.com
        DocumentRoot /home/magento/mysite.com

        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /home/magento/mysite.com/ >
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /home/magento/logs/apache.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
</VirtualHost>
<VirtualHost *:443>
        ServerName mysite.com
   DocumentRoot /home/magento/mysite.com

        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /home/magento/mysite.com/ >
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /home/magento/logs/apache.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
</VirtualHost>

Thanks for any help getting this setup! As is probably obvious from this post I am pretty lost at this point.

Solution :

A couple of things you can try:

  1. Since you’re using <VirtualHost *:443> in /etc/apache2/sites-available/mysite.com, replace both instances of Listen 443 http with

    NameVirtualHost *:443
    Listen 443
    

    in your ports.conf.

  2. As far as I can tell, you are not using the default configurations to actually serve a website.

    If I’m right, disable them:

    a2dissite default default-ssl
    

    In this case, you should also delete the line

    ServerName localhost
    

    from your httpd.conf.

  3. Make sure your newest configuration and SSL are enabled.

    a2ensite mysite.com
    a2enmod ssl
    
  4. After making any changes, remember to reload apache to activate the new configuration:

    service apache2 reload
    

below part does not seem to be correct

this is a virtual host for ssl connections on 443,

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

you are receiveing error due to inappropriate

DocumentRoot /var/www

change it to the same values as in

<VirtualHost *:443>

Leave a Reply

Your email address will not be published.