Upuntu 16.04 + Let's Encrypt verifiying that new domain works, before chaning it in cms?

by user10054712   Last Updated July 12, 2018 01:00 AM

This is probably more of a webmaster question than it is related to server administration, but given that I struggled quite a bit to get the new domain running via virtual host, I figured I'll ask here.

My situation is that I have a new domain which I would like to be the domain of my website. It is currently running on the old domain.

This is the virtual host conf of the old domain:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName domain
    ServerAlias domain
    DocumentRoot /var/www/html/store/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName domain
    ServerAlias www.domain
    DocumentRoot /var/www/html/store/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain/privkey.pem
</VirtualHost>
</IfModule>

And this is the .conf of the new one:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.

    DocumentRoot /var/www/html/store
    ServerAdmin [email protected]
    ServerName domain
    ServerAlias domain

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain [OR]
RewriteCond %{SERVER_NAME} =domain
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

However, this time certbot also created a domain-le-ssl.conf which it didn't do with my old domain.

That one contains:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.

    DocumentRoot /var/www/html/store
    ServerAdmin [email protected]
    ServerName domain
    ServerAlias domain

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
SSLCertificateFile /etc/letsencrypt/live/domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

My fear now is that I'll lock myself out of the shop system. Given that I automatically get redirected to my current url, if I enter the new one, I can't really test if the url works. It worked on the base directory without ssl. So I just hope that I configured it properly.

However, once I change the base URL in my shop system, I'm literally either locked out or it works.

My question however is, would this configuration work? What I expect to happen is, that once I change the URL in the CMS it will change. The old URL will redirect to the new one and I can safely diable the old domain, certbot for the old domains and then create a dns redirect.



Related Questions



htaccess not working at apache 2.4 virtual host

Updated January 13, 2017 01:00 AM

Can't configure two subdomains apache 2.4

Updated April 28, 2015 22:00 PM

Mass virtual hosting with Apache 2.4

Updated May 22, 2017 03:00 AM