I want to get a certificate via the letsencrypt.sh so I have to provide a challenge on HTTP.

Already I use NGINX to forward to SSL (served on a nodejs server). Now I want to still redirect everything to SSL, but not the challenge.

Here is my config

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    server_name screen.example.com;

    location /.well-known { }

    location / {
        return 301 https://$server_name$request_uri;

Opening a challenge URL still redirects me to HTTPS.

How can I fix this?

  • Hmm, when I use an empty return I can't start nginx. nginx -t fails with: nginx: [emerg] invalid number of arguments in "return" directive in /etc/nginx/.... I'm using nginx 1.4.6. What version are you running? – mgalgs Nov 11 '16 at 3:31
  • @mgalgs you have to remove the empty return statement, look at the edited config snippet. – Alex Jan 27 '18 at 16:39

Oh my, the config seems to work. I just requested the wrong path.

The letsencrypt.sh's default is .acme-challenges - I changed this to

WELLKNOWN="/usr/share/nginx/html/.well-known/acme-challenge" in config.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.