Skip to content

Commit 0eae499

Browse files
committed
Update 418 pages with correct info and tests
1 parent 8af6c87 commit 0eae499

File tree

6 files changed

+82
-7
lines changed

6 files changed

+82
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
22
/tmp/*
33
*.swp
4+
client-ca
5+
upstream-*

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ In order to run this container you'll need docker installed.
1717
* [OS X](https://docs.docker.com/mac/started/)
1818
* [Linux](https://docs.docker.com/linux/started/)
1919

20+
## Creating builds
21+
When an update has been deployed to master, tag and push the master branch to kick off a Drone build:
22+
```
23+
git tag <next_version>
24+
git push --tags
25+
```
26+
27+
## Testing Locally
28+
Authentic GEOIP credentials are needed when curling MaxMind Urls otherwise a 401 is returned. Therefore if no `GEOIP_LICENSE_KEY` secret/env var is set when running `./ci-build.sh`, a `LOCAL_TEST` variable is set to true to ensure the relevant urls are not called. This means not having to start up a Drone build every single time you want to test something and your local machine reuses any Docker cache available to it making the test/retry process much faster.
29+
30+
*MAC USERS*
31+
You will need to install wget so that this can run in the `./ci-build.sh` script:
32+
```
33+
brew install wget
34+
```
35+
2036
## Usage
2137

2238
### Environment Variables

build.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
set -eu
55
set -o pipefail
66

7+
if [ -z "$GEOIP_LICENSE_KEY" ]; then
8+
LOCAL_TEST=true
9+
else
10+
LOCAL_TEST=false
11+
fi
12+
713
GEOIP_ACCOUNT_ID="${GEOIP_ACCOUNT_ID:-123456}"
814
GEOIP_LICENSE_KEY="${GEOIP_LICENSE_KEY:-xxxxxx}"
915
GEOIP_CITY_URL="https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${GEOIP_LICENSE_KEY}&suffix=tar.gz"
@@ -52,15 +58,24 @@ mkdir -p ${MAXMIND_PATH}
5258
./configure
5359
make check install
5460
echo "/usr/local/lib" >> /etc/ld.so.conf.d/libmaxminddb.conf
55-
curl -fSL ${GEOIP_COUNTRY_URL} | tar -xz > ${MAXMIND_PATH}/GeoLite2-Country.mmdb
56-
curl -fSL ${GEOIP_CITY_URL} | tar -xz > ${MAXMIND_PATH}/GeoLite2-City.mmdb
61+
62+
# Only run if not testing locally
63+
if [ "$LOCAL_TEST" = false ]; then
64+
curl -fSL ${GEOIP_COUNTRY_URL} | tar -xz > ${MAXMIND_PATH}/GeoLite2-Country.mmdb
65+
curl -fSL ${GEOIP_CITY_URL} | tar -xz > ${MAXMIND_PATH}/GeoLite2-City.mmdb
66+
fi
67+
5768
chown -R 1000:1000 ${MAXMIND_PATH}
5869
popd
5970

6071
pushd geoipupdate
6172
sed -i 's/YOUR_ACCOUNT_ID_HERE/'"${GEOIP_ACCOUNT_ID}"'/g' GeoIP.conf
6273
sed -i 's/YOUR_LICENSE_KEY_HERE/'"${GEOIP_LICENSE_KEY}"'/g' GeoIP.conf
63-
./geoipupdate -f GeoIP.conf -d ${MAXMIND_PATH}
74+
75+
# Only run if not testing locally
76+
if [ "$LOCAL_TEST" = false ]; then
77+
./geoipupdate -f GeoIP.conf -d ${MAXMIND_PATH}
78+
fi
6479
popd
6580

6681
echo "Checking libmaxminddb module"

ci-build.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,46 @@ else
564564
echo "Testing VERBOSE_ERROR_PAGES works..."
565565
fi
566566

567+
start_test "Test VERBOSE_ERROR_PAGES is not set displays default message info" "${STD_CMD} \
568+
-e \"PROXY_SERVICE_HOST=http://${MOCKSERVER}\" \
569+
-e \"PROXY_SERVICE_PORT=${MOCKSERVER_PORT}\" \
570+
-e \"DNSMASK=TRUE\" \
571+
-e \"ENABLE_UUID_PARAM=FALSE\" \
572+
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
573+
if curl -k https://${DOCKER_HOST_NAME}:${PORT}/\?\"==\` | grep "Something went wrong." ; then
574+
echo "Testing VERBOSE_ERROR_PAGES works..."
575+
else
576+
echo "Testing VERBOSE_ERROR_PAGES failed..."
577+
exit 1
578+
fi
579+
580+
start_test "Test FEEDBACK_EMAIL is set, displays contact message info" "${STD_CMD} \
581+
-e \"PROXY_SERVICE_HOST=http://${MOCKSERVER}\" \
582+
-e \"PROXY_SERVICE_PORT=${MOCKSERVER_PORT}\" \
583+
-e \"DNSMASK=TRUE\" \
584+
-e \"ENABLE_UUID_PARAM=FALSE\" \
585+
586+
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
587+
if curl -k https://${DOCKER_HOST_NAME}:${PORT}/\?\"==\` | grep "[email protected]" ; then
588+
echo "Testing VERBOSE_ERROR_PAGES works..."
589+
else
590+
echo "Testing VERBOSE_ERROR_PAGES failed..."
591+
exit 1
592+
fi
593+
594+
start_test "Test FEEDBACK_EMAIL is not set, does not display email message info" "${STD_CMD} \
595+
-e \"PROXY_SERVICE_HOST=http://${MOCKSERVER}\" \
596+
-e \"PROXY_SERVICE_PORT=${MOCKSERVER_PORT}\" \
597+
-e \"DNSMASK=TRUE\" \
598+
-e \"ENABLE_UUID_PARAM=FALSE\" \
599+
--link \"${MOCKSERVER}:${MOCKSERVER}\" "
600+
if curl -k https://${DOCKER_HOST_NAME}:${PORT}/\?\"==\` | grep "please contact us on" ; then
601+
echo "Testing VERBOSE_ERROR_PAGES failed..."
602+
exit 1
603+
else
604+
echo "Testing VERBOSE_ERROR_PAGES works..."
605+
fi
606+
567607
echo "_________________________________"
568608
echo "We got here, ALL tests successful"
569609
clean_up

html/418-request-denied.shtml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
TIME: <!--#config timefmt="%Y-%m-%dT%H:%M:%S %Z" --><!--#echo var="date_local" -->
1212
</code>
1313
<!--#else -->
14-
<!--#set var="title" value="Something went wrong." -->
14+
<header><h1>Something went wrong.</h1></header>
1515
<p>Text entered appears suspicious. This is likely due to unusual repeat or individual special characters, i.e. @@ or && or |. Please delete any unnecessary special characters and try again.</p>
16-
<!--#if expr="${FEEDBACK_EMAIL}" -->
17-
<p>If this problem persists, please contact us on <!--#echo var="${FEEDBACK_EMAIL}" --> so we can remedy any issues and improve our service.</p>
18-
<!--#endif -->
16+
<!--#endif -->
17+
18+
<!--#if expr="${FEEDBACK_EMAIL}" -->
19+
<p>If this problem persists, please contact us on <!--#echo var="FEEDBACK_EMAIL" --> so we can remedy any issues and improve our service.</p>
1920
<!--#endif -->

nginx.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ http {
139139
# Debug information now available in headers ($http_x_naxsi_sig etc.)
140140
# Return a 418 (Teapot) status
141141
set_by_lua_file $verbose_error_pages lua/get_env.lua 'VERBOSE_ERROR_PAGES';
142+
set_by_lua_file $feedback_email lua/get_env.lua 'FEEDBACK_EMAIL';
142143
error_page 418 /nginx-proxy/418-request-denied.shtml;
143144
return 418;
144145
}

0 commit comments

Comments
 (0)