I have the following http config:
server {
listen 80;
server_name example.com;
# Necessary for Let's Encrypt Domain Name ownership validation
location /.well-known/acme-challenge/ {
root /home/vagrant/.well-known/acme-challenge/;
}
return 301 https://$host$request_uri;
}
I would like http://example.com/.well-known/acme-challenge/filename
to serve /home/vagrant/.well-known/acme-challenge/filename
while every other http request should be redirected to https.
I thought Nginx would process rules in their order, if matches, uses it, otherwise continues. But apparently not. How can I achieve what I want ?
You should move that redirect to be in the "/" block:
location / {
return 301 https://$host$request_uri;
}
They do process in order, but yours is outside of any location block, so likely is taking precedence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With