Renovar certificado ssl en odoo

SEGUIR ESTOS PASOS:


-------------------------------------------
/// Instalacion y Administracion de Nginx
-------------------------------------------

sudo su
sudo apt update
sudo apt upgrade
sudo apt install nginx
sudo systemctl enable nginx

--------------------------------DOCUMENTACION ADICIONAL--------------------------------------

sudo systemctl status nginx ----> Ver estatus de Nginx

sudo systemctl restart nginx ----> Reiniciar servicio de Nginx

sudo systemctl enable nginx ----> Habilitar el inicio automatico de nginx

--------------------------------DOCUMENTACION ADICIONAL--------------------------------------

-------------------------------------------
/// Instalacion y Administracion de UFW
-------------------------------------------

sudo apt install ufw
sudo ufw allow 'Nginx Full'
sudo ufw allow 22
sudo ufw enable
sudo ufw status

--------------------------------DOCUMENTACION ADICIONAL--------------------------------------

sudo ufw allow ssh ---> Permitir Puertos puede ser nombre o numero
sudo ufw allow 6000:6003/tcp ----> Permitir Rangos de puertos tcp
sudo ufw allow 6000:6003/udp ----> Permitir Rangos de puertos udp
sudo ufw deny from 203.0.123.5 ----> Bloquear ip de algun atacante
sudo ufw allow from 203.0.113.4 -----> Permitir conexion desde x ip a todo el servidor.
sudo ufw allow from 203.0.113.4 to any port 22 ----> Permitir un puerto desde una ip unica.
sudo ufw allow from 203.0.113.0/24 ---> Permite un segmento de red
sudo ufw status numbered ---> Muestra el ID de cada regla
sudo ufw delete 2 ---> Elimina la regla usando el ID

--------------------------------DOCUMENTACION ADICIONAL--------------------------------------

-------------------------------------------
/// Instalacion y Administracion de Certbot
-------------------------------------------

sudo apt update
sudo apt install certbot

sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

mkdir -p /var/lib/letsencrypt/.well-known
chgrp www-data /var/lib/letsencrypt
chmod g+s /var/lib/letsencrypt

--------------------------------------------
///Editar letsencrypt.conf
--------------------------------------------

sudo nano /etc/nginx/snippets/letsencrypt.conf

----------INICIO CODIGO----------------------
location ^~ /.well-known/acme-challenge/ {
  allow all;
  root /var/lib/letsencrypt/;
  default_type "text/plain";
  try_files $uri =404;
}
-----------FIN CODIGO------------------------


---------------------------------------------
/// Editar ssl.conf
---------------------------------------------

sudo nano /etc/nginx/snippets/ssl.conf


----------INICIO CODIGO----------------------
ssl_dhparam /etc/ssl/certs/dhparam.pem;

ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
ssl_prefer_server_ciphers on;

ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 30s;

add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload";
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
-----------FIN CODIGO------------------------

----------------------------------------------------------------------------------------
/// Editar odoo.ircosl.com (REMPLAZAR CON SU DOMINIO APLICAR EL REMPLAZO A TODO) SI FALLA LA RENOVACIÓN, SEGUIR DESDE AQUÍ
----------------------------------------------------------------------------------------

sudo nano /etc/nginx/sites-available/odoo.ircosl.com


------------------------INICIO CODIGO---------------------------------
server {
  listen 80;
  server_name odoo.ircosl.com odoo.ircosl.com;

  include snippets/letsencrypt.conf;
}
------------------------------FIN CODIGO-------------------------------


sudo ln -s /etc/nginx/sites-available/odoo.ircosl.com /etc/nginx/sites-enabled/

sudo systemctl restart nginx

sudo certbot certonly --agree-tos --email soporteti@ircosl.com --webroot -w /var/lib/letsencrypt/ -d odoo.ircosl.com

------------------EJEMPLO CERTIFICADO INSTALADO CORRECTAMENTE-----------------------------

 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/odoo.ircosl.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/odoo.ircosl.com/privkey.pem
   Your cert will expire on 2020-09-08. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.
-------------------------------------------------------------------------------------------

--------------------------------------------------------------------
/// Editar odoo.ircosl.com
--------------------------------------------------------------------

sudo nano /etc/nginx/sites-available/odoo.ircosl.com


------INICIO CODIGO (REMPLAZAR LA INFORMACION ANTERIOR EN LE ARHIVO)-----------------------

server {
    listen 80;
    server_name odoo.ircosl.com odoo.ircosl.com;

    include snippets/letsencrypt.conf;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name odoo.ircosl.com;

    ssl_certificate /etc/letsencrypt/live/odoo.ircosl.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/odoo.ircosl.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/odoo.ircosl.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;

    return 301 https://odoo.ircosl.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name odoo.ircosl.com;

    ssl_certificate /etc/letsencrypt/live/odoo.ircosl.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/odoo.ircosl.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/odoo.ircosl.com/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;

    # . . . other code
}
------FIN CODIGO (REMPLAZAR LA INFORMACION ANTERIOR EN LE ARHIVO)-----------------------


sudo systemctl reload nginx

------------------------------------------------
//// Renovar Certificados Vencidos
------------------------------------------------

service nginx stop

sudo certbot certonly --agree-tos --email soporteti@ircosl.com --webroot -w /var/lib/letsencrypt/ -d odoo.ircosl.com

service nginx start


-----------------------------------------
/// Configuracion Final de SSL y Nginx
-----------------------------------------

-----------------------------------------
/// Editar doo.odoo.ircosl.com
-----------------------------------------

sudo nano /etc/nginx/sites-enabled/odoo.ircosl.com


-----------INICIO CODIGO (REMPLAZAR LA INFORMACION ANTERIOR EN LE ARHIVO)-----------------

# Odoo servers
upstream odoo {
 server 127.0.0.1:8069;
}

upstream odoochat {
 server 127.0.0.1:8072;
}

# HTTP -> HTTPS
server {
    listen 80;
    server_name odoo.ircosl.com;

    include snippets/letsencrypt.conf;
    return 301 https://odoo.ircosl.com$request_uri;
}

# WWW -> NON WWW
#server {
#    listen 443 ssl http2;
#    server_name odoo.ircosl.com;

#    ssl_certificate /etc/letsencrypt/live/odoo.ircosl.com/fullchain.pem;
#    ssl_certificate_key /etc/letsencrypt/live/odoo.ircosl.com/privkey.pem;
#    ssl_trusted_certificate /etc/letsencrypt/live/odoo.ircosl.com/chain.pem;
#    include snippets/ssl.conf;

#    return 301 https://odoo.ircosl.com$request_uri;
#}

server {
    listen 443 ssl http2;
    server_name odoo.ircosl.com;

    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;

    # Proxy headers
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;

    # SSL parameters
    ssl_certificate /etc/letsencrypt/live/odoo.ircosl.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/odoo.ircosl.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/odoo.ircosl.com/chain.pem;
    include snippets/ssl.conf;

    # log files
    access_log /var/log/nginx/odoo.access.log;
    error_log /var/log/nginx/odoo.error.log;

    # Handle longpoll requests
    location /longpolling {
        proxy_pass http://odoochat;
    }

    # Handle / requests
    location / {
       proxy_redirect off;
       proxy_pass http://odoo;
    }

    # Cache static files
    location ~* /web/static/ {
        proxy_cache_valid 200 90m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://odoo;
    }

    # Gzip
    gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
    gzip on;
}

------FIN CODIGO (REMPLAZAR LA INFORMACION ANTERIOR EN LE ARHIVO)-----------------------


sudo systemctl restart nginx


--------------------------------------
/// Editar odoo12.conf
--------------------------------------

sudo nano /etc/odoo12.conf  --> Instalacion Manual Link ---> https://linuxize.com/post/how-to-deploy-odoo-12-on-ubuntu-18-04/

sudo nano /etc/odoo-server.conf --> Instalacion con Script (DEBEN CAMBIAR EL ADMIN)


------------------------------INICIO CODIGO-(AGREGAR ABAJO)---------------------------------

proxy_mode = True

xmlrpc_interface = 127.0.0.1
netrpc_interface = 127.0.0.1

workers = 2

--------------------------------FIN CODIGO-(AGREGAR ABAJO)---------------------------------


sudo systemctl restart odoo12 --> Instalacion Manual Link ---> https://linuxize.com/post/how-to-deploy-odoo-12-on-ubuntu-18-04/

sudo systemctl restart odoo-server --> Instalacion con Script


RENOVACIÓN DE CERTIFICADO FALLIDA

Para renovar el certificado en caso de que no funcione el procedimiento indicado de renovación, debemos lanzar los siguientes comandos:

rm -r /etc/letsencrypt/archive/example.dominio.com
rm -r /etc/letsencrypt/live/example.dominio.com
rm -r /etc/nginx/sites-available/example.dominio.com
rm -r /etc/nginx/sites-enable/example.dominio.com

A continuación, seguir los pasos desde la línea que pone «SI FALLA LA RENOVACIÓN, SEGUIR DESDE AQUÍ»

Deja una respuesta 0

Your email address will not be published. Required fields are marked *