I'm trying to move from self-signed certificates to Let's Encrypt certificates on my nginx webserver.
Currently, I redirect all requests to http/80
to https/443
, which uses a self signed certificate I created a while ago.
Now - from what I understand Let's Encrypt makes a request to port 80 (as I am using the webroot
option of certbot
). These requests are redirected, which renders the certificate generation unsuccessful.
I tried to achieve this with the following server block, listening at port 80:
server {
listen 80;
server_name sub.domain.tld;
server_tokens off;
location /.well-known {
root /var/www/letsencrypt;
}
location / {
return 301 https://$host$request_uri;
}
}
But requests to /.well-known
are redirected to https/443
anyways.
How can I redirect all requests from http/80
to https/443
, except the requests to /.well-known/
?
webroot
ofcertbot
option requires plain http.wget
/curl