1

I'm trying to set up Apache virtual hosts on my Raspberry Pi so I can host 2 different websites with 2 different domains. I've done it before with no problems, but now I'm having no luck.

Since setting up the virtual hosts, all SSL connections are now refused (ERR_CONNECTION_REFUSED) and any HTTP connections go straight to the server root (var/www).

My virtual host files look like this:

    <IfModule mod_ssl.c>
        <VirtualHost *:80>
        ServerName roboguy99.co.uk
        </VirtualHost>
        <VirtualHost *:443>
            ServerAdmin roboguy99@gmail.com
            ServerAlias www.roboguy99.co.uk
            ServerName roboguy99.co.uk
            DocumentRoot /var/www/roboguy99.co.uk/public_html
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
            SSLEngine on
            SSLCertificateFile /etc/apache2/ssl/apache.crt
            SSLCertificateKeyFile /etc/apache2/ssl/apache.key
            <FilesMatch "\.(cgi|shtml|phtml|php)$">
                            SSLOptions +StdEnvVars
            </FilesMatch>
            <Directory /usr/lib/cgi-bin>
                            SSLOptions +StdEnvVars
            </Directory>
            BrowserMatch "MSIE [2-6]" \
                            nokeepalive ssl-unclean-shutdown \
                            downgrade-1.0 force-response-1.0
            BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
        </VirtualHost> 
    </IfModule>

and

<IfModule mod_ssl.c>
    <VirtualHost *:80>
    ServerName choughsttc.co.uk
    </VirtualHost>
    <VirtualHost *:443>
        ServerAdmin roboguy99@gmail.com
    ServerAlias www.choughsttc.co.uk
        ServerName choughsttc.co.uk
        DocumentRoot /var/www/choughsttc.co.uk/public_html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                        SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                        SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch "MSIE [2-6]" \
                        nokeepalive ssl-unclean-shutdown \
                        downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
    </VirtualHost> 
</IfModule>

And my ports.conf like this:

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

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.
    NameVirtualHost *:443
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    NameVirtualHost *:443
    Listen 443
</IfModule>

It's probably worth noting that my server was previously set up to work with 1 domain which automatically redirected all HTTP traffic to SSL (and was working fine).

I did have many a Google in search for a solution, however found nothing. If the soultion is stupidly easy, I'm sorry. If you need to see more files, I'll upload them. All help is appriciated.

migrated from raspberrypi.stackexchange.com May 31 '15 at 13:24

This question came from our site for users and developers of hardware and software for Raspberry Pi.

  • Are you getting anything in the log files? I'm not sure if you're aware but having multiple vhosts with SSL can be a real pain to setup. Have you tried things like digicert.com/ssl-certificate-installation-apache.htm and digicert.com/ssl-support/… – pcnate Jun 1 '15 at 23:35
  • @pcnate nothing in the log files. I'll have a look at those guides, thanks. – Jake Stanger Jun 2 '15 at 15:46
  • When having virtual host setup problems, the first port of call should always be the output of "apachectl -S" (or possibly "httpd -S"). Please add this to your post – Unbeliever Oct 2 '16 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.