Tutorial Proxy Reverso com Nginx no Debian 12 (bookwork) com Certificado Digital (certbot)

Tutorial Proxy Reverso com Nginx no Debian 12 (bookwork) com Certificado Digital (certbot)

Para instalar e configurar o Proxy Reverso no Debian 12 (bookworm) proceda com os seguintes passos:

1º – Instalar nginx

apt install nginx certbot python3-certbot-nginx -y

2ª Crei um Vhost em /etc/nginx/sites-enabled

cd /etc/nginx/sites-enabled
vim site01.conf

server {
  server_name app.site01.com;
  set $upstream 127.0.0.1:5000;

  underscores_in_headers on;
  location /.well-known {
    alias /var/www/ssl-proof/.well-known;
  }

  location / {
    proxy_pass_header Authorization;
    proxy_pass http://$upstream;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Ssl on; # Optional

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_http_version 1.1;
    proxy_set_header Connection “”;
    proxy_buffering off;

    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;
  }
}

Para checar as sintaxes do arquivo de configuração, execute:

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

3º Gerando Certificados

certbot --nginx -d site01.com -d app.site01.com

 

Sobre o Autor

Diego Elcain administrator