Created
January 19, 2017 13:15
-
-
Save MrYoda/498b8c248f6c490f26bd1bc4a81506f8 to your computer and use it in GitHub Desktop.
Nginx "Ping" via HTTP with CORS and without any files and backends
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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