I have a redirect to force https:
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
Works great, but I would like to be able to hit a single text file through http using the echo module:
server {
listen 80;
location /ping {
echo "http_pong";
}
server_name example.com;
return 301 https://example.com$request_uri;
}
Unfortunately I can never get to /ping
as I get the 301 redirect instead. How can I prevent the global redirect from applying to that single location?
Try putting redirect under
location /
, like this:Be aware - "echo" is deprecated. Use "return"
}