Servidor Web com NGINX — Instalação e configuração de certificado SSL em sistemas baseados em RHEL

Photo by Towfiqu barbhuiya on Unsplash

Considerações

  • Para este tutorial, vamos utilizar um domínio fictício: “example.com”.
  • Todos os comandos serão executados a partir de nossa “home”.

Instalação do nss-tools

sudo dnf install nss-tools

Instalação do mkcert

export VER="v1.4.3"
wget -O mkcert https://github.com/FiloSottile/mkcert/releases/download/${VER}/mkcert-${VER}-linux-amd64
chmod +x mkcert
sudo mv mkcert /usr/local/bin/
mkcert -install
Created a new local CA 💥
The local CA is now installed in the system trust store! ⚡️
The local CA is now installed in the Firefox and/or Chrome/Chromium trust store (requires browser restart)! 🦊

Gerando os certificados

mkcert example.com www.example.com
Created a new certificate valid for the following names 📜
- "example.com"
- "www.example.com"

The certificate is at "./example.com+1.pem" and the key at "./example.com+1-key.pem" ✅

It will expire on 30 January 2023 🗓

Estrutura de pastas para o armazenamento dos Certificados

sudo mkdir -p /etc/pki/nginx/ mkdir -p /etc/pki/nginx/private/
sudo mv example.com+1.pem /etc/pki/nginx
sudo mv example.com+1-key.pem /etc/pki/nginx/private
sudo chcon -R -t httpd_sys_content_t /etc/pki/nginx/*.pem
sudo chcon -R -t httpd_sys_content_t /etc/pki/nginx/private/*.pem

Configuração do Server Block

code /etc/nginx/conf.d/example.com.conf
sudo systemctl restart nginx

Apontando os domínios para o servidor local

code /etc/hosts
127.0.0.1   example.com www.example.com
::1 example.com www.example.com

Tudo pronto, nossos certificados estão devidamente configurados.

--

--

Desenvolvedor Front-end e UI/UX Designer.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Marcelo Albuquerque

Marcelo Albuquerque

Desenvolvedor Front-end e UI/UX Designer.