Configuration

SSL configuration valid with Let’s Encrypt

To configure a valid certificate we must first change the host name of the EC2 instance to allow us to generate the certificate. AWS does not allow us to generate certificates for the default name of the instance, because names (and IPs are volatile).

Edit the /etc/nginx/sites-enabled/nagios4.conf file and configure the domain name in the server_name entries. Be sure to uncomment them. If, for example, we use the nagios4.imaxe.cloud entry, the configuration would look like this:

server {
    listen 80;
    server_name nagios4.imaxe.cloud;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;

    server_name nagios4.imaxe.cloud;

then restart the service using the command:

service nginx restart

the last step is to use certbot to configure the registration and renewal of our certificate, with the command:

certbot --nginx --agree-tos --register-unsafely-without-email -d nagios4.imaxe.cloud

after executing this command you will be able to access the instance using https://elnombredetudominio

Remember to change the example domain name used here to yours