Last active
January 20, 2021 05:21
-
-
Save r0mdau/e46b6309785cf7ede6f6752ce235fa16 to your computer and use it in GitHub Desktop.
Test Nginx conf quickly
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
server { | |
listen 80; | |
server_name localhost; | |
location ~ /watch { | |
default_type application/json; | |
if ($arg_device = desktop) { | |
return 200 '{"message": "Desktop found !"}'; | |
} | |
return 301 $scheme://$host/success?device=$arg_device; | |
} | |
location ~ /success { | |
default_type application/json; | |
return 200 '{"message": "Success $arg_device"}'; | |
} | |
error_page 404 /404.html; | |
error_page 500 502 503 504 /50x.html; | |
} | |
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
docker run --name nginx-test -p 80:80 -v $PWD/default.conf:/etc/nginx/conf.d/default.conf:ro -d nginx | |
# reload after changes in default.conf | |
docker exec nginx-test nginx -s reload | |
# test | |
curl localhost/watch?device=desktop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment