Replaced cert as new domain nginx config issue


#1

First here is what I did on Ubuntu 16/nginx Digital Ocean droplet:

  1. Installed free SSL cert as per their guide for old domain accessmygp.com.au, all good.
  2. Domain changed to accessspecialist.com.au.
  3. Removed old cert and installed cert for new domain, again all good and accessspecialist.com.au is working.

However I notice /etc/nginx/sites-enabled/default still has references to old domain. My question is can I just manually update this file with the new domain and restart nginx? Or is there a better way?

Here is the relavant bits of the file:

/* /etc/nginx/sites-enabled/default */

server {
    ...

    server_name accessspecialist.com.au www.accessspecialist.com.au;
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/accessspecialist.com.au/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/accessspecialist.com.au/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    ...

server {
    if ($host = www.accessmygp.com.au) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = accessmygp.com.au) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name accessmygp.com.au www.accessmygp.com.au;
    listen 80;
    return 404; # managed by Certbot

    ...

#2

I would just edit this file and restart nginx.
However, I would first verify that there is no other file that may be conflicting with such a change.
grep -ErI 'accessmygp.com.au|accessspecialist.com.au' /etc/nginx/


#3

Thanks @rg305 I have successfully done the following:

  • backed up conf files
  • edit files
sudo nginx -t
sudo service nginx restart

#4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.