Skip to content

Instantly share code, notes, and snippets.

@r0mdau
Last active January 20, 2021 05:21
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 r0mdau/e46b6309785cf7ede6f6752ce235fa16 to your computer and use it in GitHub Desktop.
Save r0mdau/e46b6309785cf7ede6f6752ce235fa16 to your computer and use it in GitHub Desktop.
Test Nginx conf quickly
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;
}
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