#Linux

#Apache

#DynDNS

#SSL

Multiple DynDNS, one Server

5 years ago

36

Short Guide on how to set up multiple websites on one Server with DynDNS, Apache and Let's Encrypt for SSL Redirect.

DynDNS

First, let's set up the DyDNS-Entries. There are a multitude of DyDNS-Providers, I'm using no-ip.

We need one DNS-Host (A-Record) for the DynDNS to resolve the IP.



The other Domains can be set up as DNS Alias (CNAME-Records) that point to the DNS-Host.



It may take a while for the DNS-Entries to be propageted to the DSN-Servers, but if you've configured your Router, you should be able to ping your server now.

While at it, you may want to open the ports of your Router. I'll skip this step here.


Apache Configuration

On your Server, go to /etc/apache2/sites-available/ and


  • set up a files %DOMAIN_NAME%.conf for the http-configuration:

    <VirtualHost *:80>
        ServerName %DOMAIN_NAME%
        ServerAlias www.%DOMAIN_NAME%
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =%DOMAIN_NAME%
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>

  • and a File %DOMAIN_NAME%-ssl.conf for the SSL-Configuration:

    <IfModule mod_ssl.c>
    <VirtualHost *:443>
        ServerAdmin admin@%DOMAIN_NAME%
        ServerName %DOMAIN_NAME%
        ServerAlias www.%DOMAIN_NAME%
        DocumentRoot /var/www/%DOMAIN_NAME%
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLCertificateFile /etc/letsencrypt/live/%DOMAIN_NAME%/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/%DOMAIN_NAME%/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
    </VirtualHost>
    </IfModule>

Create these files for each of the Domains and replace %DOMAIN_NAME% accordingly.

Now you can copy your Website Files to /var/www/%DOMAIN_NAME% and http should already work!


SSL with Let's Encrypt

Now for SSL, simply execute sudo certbot --apache and follow the instructions to create your SSL certificates for all your domains and check the .conf files again.