Search code examples
ssl-certificatevirtualhostindexofself-signedapache2.4

apache 2.4 virtual host brings me to "Index of /"


i followed the following instructions: virtual host, https.

As i use a DynDNS for my locas hosted webside, my final 000-default.conf looks like this:

<VirtualHost *:443>
                ServerName www.mydomain.dyndns.xx
                ServerAdmin webmaster@localhost
                DocumentRoot /var/www/html/mydomain.dyndns.xx/
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLCertificateFile /etc/apache2/ssl/ca.crt
                SSLCertificateKeyFile /etc/apache2/ssl/ca.key

                ErrorLog ${APACHE_LOG_DIR}/www.virtualhost1.com_error.log
                CustomLog ${APACHE_LOG_DIR}/www.virtualhost1.com_access.log combined
</VirtualHost>

I additionaly configured in /etc/apache2/apache.conf the follwoing:

<Directory /var/www/html/mydomain.dyndns.xx>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

and in the /etx/host

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.1.1       raspberrypi

192.168.x.x     www.mydomain.dyndns.xx

when i try to open the URL of the page it desplays me the "Indes of /" on Port 80, when i klick on those files, i get the http:// mydomain.dyndns.xx/mydomain.dyndns.xx.index.php

if i call the https:// then i get an ERR_CONNECTION_REFUSED on my browser.

Thank you for the help!


Solution

  • Your 000-defualt.conffile looks perfectly file . Although when using SSL certificates make sure to make the following changes :

    EDIT PORTS.CONF FILE

    Edit your ports.conf file and add the following line :

        Listen 192.168.x.x:443 
    

    This tells the apache to listen to incoming connections from the specified Ip : port 443

    TESTING CONFIG ON LOCALHOST

    You can test the config on your system first by making the following entry in /etc/hosts file:

        127.0.0.x    www.mydomain.dyndns.xx
    

    And adding the following to ports.conf file:

        Listen 127.0.0.x:443
    

    Make sure to comment out 192.168.x.x www.mydomain.dyndns.xx entry in ports.conf file before testing the config

    ENABLE MOD_SSL

    Enable mod_ssl by issuing the following command:

        sudo a2enmod ssl
    

    RESTART APACHE

    Restart apache2 : sudo systemctl restart apache2

    In your browser point to your domain name : https://www.mydomain.dyndns.xx