Nginx prevent redirect for a single location
Try putting redirect under location /
, like this:
server {
listen 80;
server_name example.com;
location /ping {
echo "http_pong";
}
location / {
return 301 https://example.com$request_uri;
}
}