<div dir="auto">I believe you need to put the `return 301 ...` inside a location block too. Otherwise, it overrides all the location blocks.<div dir="auto"><br></div><div dir="auto">I'm on my phone now, but I'll try to share a sample file from one of my servers (that works as you want it) when I get back to my computer.</div><div dir="auto"><br></div><div dir="auto">Moshe</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 2, 2018, 5:03 PM Mik J via nginx <<a href="mailto:nginx@nginx.org">nginx@nginx.org</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-6100706546047295826ydp1a37a54cyahoo-style-wrap" style="font-family:Helvetica,Arial,sans-serif;font-size:16px">Hello,<br><div><br><div>I'd like to be able to offer let's encrypt in port 80 only and redirect everything else to port 443<br><div><br><span>server {<br> listen 80;<br> listen [::]:80;<br> listen 443;<br> listen [::]:443;<br> server_name <a href="http://www.mydomain.org" rel="nofollow noreferrer" target="_blank">http://www.mydomain.org</a> blog.<span><span><a href="http://mydomain.org" target="_blank" rel="noreferrer">mydomain.org</a></span></span>;<br> location ^~ /.well-known/acme-challenge { default_type "text/plain"; root /var/www/letsencrypt; }<br> location = /.well-known/acme-challenge/ { return 404; }<br> return 301 https:// <span><span><a href="http://mydomain.org" target="_blank" rel="noreferrer">mydomain.org</a></span></span>;<br>}<br><br></span><div>My problem is that everything is redirected and I cannot access a file in <span><span>/var/www/letsencrypt/<span><span>.well-known/acme-challenge</span></span><br></span></span><div><span><span>When I comment the return 301 it works but I loose the redirection.</span></span></div><div><br><div><div>It seems to me that nginx parses everything where I would expect it to stop at<br><div><span><span>location ^~ /.well-known/acme-challenge { default_type "text/plain"; root /var/www/letsencrypt; }</span><br></span><span></span><div><br>Does anyone know the trick ?<br></div></div></div><span><span></span></span></div></div></div></div></div></div></div></div>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank" rel="noreferrer">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote></div>