Skip to content

Instantly share code, notes, and snippets.

@MrYoda
Created January 19, 2017 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrYoda/498b8c248f6c490f26bd1bc4a81506f8 to your computer and use it in GitHub Desktop.
Save MrYoda/498b8c248f6c490f26bd1bc4a81506f8 to your computer and use it in GitHub Desktop.
Nginx "Ping" via HTTP with CORS and without any files and backends
# Ping location
location /ping {
add_header "Allow" "GET, OPTIONS, HEAD" always;
# CORS headers
add_header "Access-Control-Allow-Origin" "*";
add_header "Access-Control-Allow-Methods" "GET, OPTIONS, HEAD";
add_header "Access-Control-Allow-Headers" "Accept,Accept-Encoding,Cache-Control,Content-Type,DNT,If-Modified-Since,Origin,User-Agent,X-Requested-With";
if ( $request_method !~ ^(GET|OPTIONS|HEAD)$ ) {
return 405 "Only GET, OPTIONS, HEAD allowed";
}
add_header "Content-Type" "text/plain";
return 200 "pong";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment