So I have made a basic website for a domain and I'm able to run it with http just fine (when I disable http redirection to https and give it the root to my site). However, I tried setting up https with Let's Encrypt and I am unable to make it work so far.
Here's what I used to run certbot:
sudo certbot --nginx
I then left the answer blank when it asked me which url I want to apply it for, www.error502.com or error502.com, so it should be applied to both.
I had already tried it with Apache, but encountered a similar error, so I renewed that when switching to Nginx.
The commands do not give any sort of an error.
I have everything necessary allowed in my cloud provider and am running another site under the same subnet, which uses let's encrypt and works perfectly fine.
Firewall-wise, I have allowed ports 80 and 443 in iptables and ufw is disabled. I used the commands:
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
I have tried running the site in Let's Debug and get the following:
https://pastebin.com/xxfaTkDX
I can make it so that the http site does not redirect and loads the site root, which removes that error, but https still fails to work (and I want to redirect to https).
Here's my Nginx config:
https://pastebin.com/JubMe1P0
My domain is: error502.com
My web server is (include version): Nginx 1.18.0
The operating system my web server runs on is (include version): Ubuntu 22.04
My hosting provider, if applicable, is: Oracle Cloud
I can login to a root shell on my machine (yes or no, or I don't know): yes
I'm using a control panel to manage my site (no, or provide the name and version of the control panel): no
The version of my client is (e.g. output of certbot --version
or certbot-auto --version
if you're using Certbot): certbot 1.21.0
I have, in addition, tried it with Caddy, which automatically does the https stuff, and face the same issue. The Caddyfile used there is as follows:
error502.com {
# Set this path to your site's directory.
root * /var/www/error502
# Enable the static file server.
file_server
}
Also If I run:
sudo netstat -anne | grep 443
I get:
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 0 84742
tcp6 0 0 :::443 :::* LISTEN 0 84741
So the server is listening for the https port.