mirror of
https://github.com/dcarrillo/docker-nginx.git
synced 2024-11-14 03:31:12 +00:00
commit
b9f3f51de0
@ -69,7 +69,7 @@ http {
|
||||
server_name _ "";
|
||||
access_log /dev/fd/1;
|
||||
|
||||
location = /geoip {
|
||||
location = /ip {
|
||||
limit_req zone=limited4 burst=5 nodelay;
|
||||
if ($http_user_agent ~* (?:curl|wget|libwww-perl|python|ansible-httpget|HTTPie|WindowsPowerShell|http_request|^$)) {
|
||||
return 200 "$remote_addr\n";
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
set -e
|
||||
|
||||
if [ x"$DEBUG" = xtrue ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
trap _catch_err ERR
|
||||
trap _cleanup EXIT
|
||||
|
||||
@ -63,16 +67,14 @@ docker run --name "${NGINX_VERSION}"_test --rm -p 65521:80 -p 65523:443 \
|
||||
-v "$TMP_DIR"/dhparams.pem:/tmp/dhparams.pem:ro \
|
||||
-d "${DOCKER_IMAGE}":"${NGINX_VERSION}"
|
||||
|
||||
printf "\nTesting http request: %s:%s\n" "${DOCKER_IMAGE}" "${NGINX_VERSION}"
|
||||
STATUS_CODE=$(curl -s -m 5 -o /dev/null -w "%{http_code}" http://localhost:65521/nginx_status)
|
||||
_check_status_code "$STATUS_CODE"
|
||||
for request in http://localhost:65521/nginx_status https://localhost:65523/nginx_status; do
|
||||
printf "\nRequesting %s\n" $request
|
||||
STATUS_CODE=$(curl -s -k -m 5 -o /dev/null -w "%{http_code}" $request)
|
||||
_check_status_code "$STATUS_CODE"
|
||||
done
|
||||
|
||||
printf "\nTesting https request: %s:%s\n" "${DOCKER_IMAGE}" "${NGINX_VERSION}"
|
||||
STATUS_CODE=$(curl -s -m 5 -o /dev/null -w "%{http_code}" --http2 -k https://localhost:65523/)
|
||||
_check_status_code "$STATUS_CODE"
|
||||
|
||||
printf "\nTesting http geoip request: %s:%s\n" "${DOCKER_IMAGE}" "${NGINX_VERSION}"
|
||||
RESPONSE=$(curl -s -m 5 http://localhost:65521/geoip)
|
||||
printf "\nRequesting http://localhost:65521/ip\n"
|
||||
RESPONSE=$(curl -s -m 5 http://localhost:65521/ip)
|
||||
_check_if_is_ip "$RESPONSE"
|
||||
|
||||
echo "All tests succeeded !"
|
||||
|
Loading…
Reference in New Issue
Block a user