My domain is: fdm.niradynamics.se
My web server is (include version): nginx 17
The operating system my web server runs on is (include version): Debian 9
Hi!
I want ngnix to redirect http to https. To accomplish this I have added the following to my nginx config:
server {
# Redirect http to https.
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
which works well. But when using “certbot --nginx”, the config is updated (added to my main server block: listen 80; # managed by Certbot). Thus the redirect no longer works. Is there an easy fix to this?
EDIT: I could do something like this: sed -i '/listen 80; # managed by Certbot/d' /etc/nginx/conf.d/default.conf
. But I’m not sure if certbot will update the config again in its cron-job.
Thanks in advance!