user3748883
user3748883

Reputation: 339

Nginx doesn't work in https with certbot letsencrypt

I have executed the steps shown in the certbot web and have already generated the certificates. They are in /etc/letsencrypt/live/example.com/ and this is my /etc/nginx/sites-available/default:

# Default server configuration
#
server {
listen 80 default_server;
#listen [::]:80 default_server;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

# server_name _;
server_name example.com;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#   deny all;
#}

listen 443 ssl; # managed by Certbot

ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;      # managed by Certbot
ssl_session_cache shared:le_nginx_SSL:1m; # managed by Certbot
ssl_session_timeout 1440m; # managed by Certbot

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # managed by Certbot
ssl_prefer_server_ciphers on; # managed by Certbot

ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-ECDSA-AES128-SHA ECDHE-ECDSA-AES256-SHA ECDHE-ECDSA-AES128-SHA256 ECDHE-ECDSA-AES256-SHA384 ECDHE-RSA-AES128-GCM-SHA256 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-RSA-AES128-SHA ECDHE-RSA-AES128-SHA256 ECDHE-RSA-AES256-SHA384 DHE-RSA-AES128-GCM-SHA256 DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES128-SHA DHE-RSA-AES256-SHA DHE-RSA-AES128-SHA256 DHE-RSA-AES256-SHA256 EDH-RSA-DES-CBC3-SHA"; # managed by Certbot

if ($scheme != "https") {
  return 301 https://$host$request_uri;
} # managed by Certbot

}

If I enter in example.com it redirects well to https://example.com

The problem is that it always shows an error indicating that there has been an error showing the page.

The DNS is well redirected with an A entry for example.com.

PD.: assume that example.com is my domain

Upvotes: 1

Views: 1182

Answers (1)

user3748883
user3748883

Reputation: 339

I forgot to redirect the port 443 in my router!

Upvotes: 3

Related Questions