Why am I unable to access my website after installing an SSL certificate using Certbot? (running Ubuntu and Nginx)
I can not establish a connection to port 443 on my nginx server.
I needed port 443 to enable https connections, I used certbot to install an ssl certificate, and I went with the default installation, and default instructions in this guide
Even though I've set the 'nginx full' command to open both http and https ports, I double checked to make sure that port 443 is really open by running the following command sudo lsof -i -P -n | grep LISTEN
, and in the response, I got port 443 as being used by nginx
I tried tools like cURL to test my ports, port 80 works just fine, but I get no response from port 443
I lack experience with server administration and I tried to check other resources but I don't know what else to do.
my sites-available configuration:
server {
root /var/www/muhammed-aldulaimi.com/html;
index index.html index.htm index.nginx-debian.html;
server_name muhammed-aldulaimi.com www.muhammed-aldulaimi.com;
location / {
try_files $uri $uri/ =404;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/muhammed-aldulaimi.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/muhammed-aldulaimi.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.muhammed-aldulaimi.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = muhammed-aldulaimi.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name muhammed-aldulaimi.com www.muhammed-aldulaimi.com;
return 404; # managed by Certbot
}
ufw status:
22/tcp ALLOW Anywhere
Nginx Full ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
Solution 1:
After verifying that there was no issue in ubuntu's firewall settings, I assumed that the issue lied in the web host itself. I was using AWS Lightsail, and turned out that Lightsail only accepted connections coming from port 22 and 80. Adding a rule that accepted other ports in the Networking tab; solved my issue.