Nginx location alias + redirection

后端 未结 1 532
情深已故
情深已故 2021-01-19 07:30

I want to be able, if the request tries to access /.well-known/acme-challenge/ to serve the matching file if found.

If the request is someth

1条回答
  •  孤街浪徒
    2021-01-19 07:55

    Place the return statement inside a location block:

    For example:

    server {
        listen 8080;
        server_name my_example.com;
    
        location /.well-known/acme-challenge/ {
            root /var/www/encrypt;
        }
        location / {
            return 301 https://$server_name$request_uri;
        }
    }
    

    Also, simplified your other location block.

    0 讨论(0)
提交回复
热议问题