diff --git a/roles/nginx/files/errors/429.html b/roles/nginx/files/errors/429.html new file mode 100644 index 0000000000000000000000000000000000000000..fc14a1e02a81d02ef015f674474be79e851b4ff7 --- /dev/null +++ b/roles/nginx/files/errors/429.html @@ -0,0 +1,34 @@ + + + + 429 - Rate limited + + + +
+ +

too many requests

+

+ You sent too many requests for a protected URL + in a short amount of time. Wait a while and + try again later. +

+
+ + diff --git a/roles/nginx/files/errors/451.html b/roles/nginx/files/errors/451.html new file mode 100644 index 0000000000000000000000000000000000000000..0c8ebe0f9bccd5ca6670d698576f25d24e3e4099 --- /dev/null +++ b/roles/nginx/files/errors/451.html @@ -0,0 +1,33 @@ + + + + 451 - Unavailable For Legal Reasons + + + +
+ +

Unavailable for legal reasons

+

+ This request may not be serviced because some + law court has ordered us not to show it to you. +

+
+ + diff --git a/roles/nginx/files/errors/500.html b/roles/nginx/files/errors/500.html new file mode 100644 index 0000000000000000000000000000000000000000..78b22cf22cd1bdd48874980fed3ed499bfdf854a --- /dev/null +++ b/roles/nginx/files/errors/500.html @@ -0,0 +1,39 @@ + + + + 500 - Internal Server Error + + + +
+ +

the site has an error :-(

+

+ Something went wrong...
+ maybe you could try again later. +

+

+ Perhaps maintenance is ongoing?
+ Check out + our blog + +

+
+ + diff --git a/roles/nginx/files/errors/502.html b/roles/nginx/files/errors/502.html new file mode 100644 index 0000000000000000000000000000000000000000..9be65daa22e417418a637963fc353f85358ac5ad --- /dev/null +++ b/roles/nginx/files/errors/502.html @@ -0,0 +1,39 @@ + + + + 502 - Server timed out + + + +
+ +

the server timed out :-(

+

+ Something went wrong...
+ maybe you could try again later. +

+

+ Perhaps maintenance is ongoing?
+ Check out + our blog + +

+
+ + diff --git a/roles/nginx/files/errors/503.html b/roles/nginx/files/errors/503.html new file mode 100644 index 0000000000000000000000000000000000000000..9adb7e74a561bfea966e3c42d27fffb192a4abe9 --- /dev/null +++ b/roles/nginx/files/errors/503.html @@ -0,0 +1,39 @@ + + + + 503 - Service unavailable + + + +
+ +

service unavailable :-(

+

+ Something went wrong...
+ maybe you could try again later. +

+

+ Maintenance seems to be ongoing.
+ Check out + our blog + +

+
+ + diff --git a/roles/nginx/files/errors/504.html b/roles/nginx/files/errors/504.html new file mode 100644 index 0000000000000000000000000000000000000000..a0c98ee67ca2282cfd4e3295a792ecc031fc4fff --- /dev/null +++ b/roles/nginx/files/errors/504.html @@ -0,0 +1,39 @@ + + + + 504 - Gateway timeout + + + +
+ +

service unavailable :-(

+

+ Something went wrong...
+ maybe you could try again later. +

+

+ Maintenance seems to be ongoing.
+ Check out + our blog + +

+
+ + diff --git a/roles/nginx/files/errors/Rstar22-t.png b/roles/nginx/files/errors/Rstar22-t.png new file mode 100644 index 0000000000000000000000000000000000000000..fb5b105901909551862cbdd373c3e9ebc3800d80 Binary files /dev/null and b/roles/nginx/files/errors/Rstar22-t.png differ diff --git a/roles/nginx/files/errors/bomb-small-c.png b/roles/nginx/files/errors/bomb-small-c.png new file mode 100644 index 0000000000000000000000000000000000000000..8135c574acf1c92e9d9f2112a41613d3ee68b0a1 Binary files /dev/null and b/roles/nginx/files/errors/bomb-small-c.png differ diff --git a/roles/nginx/tasks/nginx.yml b/roles/nginx/tasks/nginx.yml index 7babad0b52884a0afbc4215714f6fdc8b0ee1746..e225048f7faa0c805841497ee63fcd151a7b30a4 100644 --- a/roles/nginx/tasks/nginx.yml +++ b/roles/nginx/tasks/nginx.yml @@ -148,6 +148,17 @@ src: favicon.ico dest: /var/www/html/favicon.ico +- name: Create the custom error directory + file: + path: /var/www/html/__errors + state: directory + +- name: Copy custom error messages + copy: + src: "{{ item }}" + dest: /var/www/html/__errors/ + with_fileglob: "errors/*" + # Create the cache directory. - file: path: /var/cache/nginx diff --git a/roles/nginx/templates/config/conf.d/proxy.conf b/roles/nginx/templates/config/conf.d/proxy.conf index 6dfcf9b3e9052718cdea96ca05672392a9d43f94..30af6f7ae35964bbc6ffed2eae862164fc7e8ad1 100644 --- a/roles/nginx/templates/config/conf.d/proxy.conf +++ b/roles/nginx/templates/config/conf.d/proxy.conf @@ -29,4 +29,4 @@ proxy_cache_valid 404 1m; proxy_cache_min_uses 2; # Show our own error pages, not the remote ones. -#proxy_intercept_errors on; +proxy_intercept_errors on; diff --git a/roles/nginx/templates/config/snippets/custom-errors.conf b/roles/nginx/templates/config/snippets/custom-errors.conf new file mode 100644 index 0000000000000000000000000000000000000000..5ca8e9a7d8458a9f9db52b48b25e946abfb264be --- /dev/null +++ b/roles/nginx/templates/config/snippets/custom-errors.conf @@ -0,0 +1,18 @@ +# Global error pages. +location /__errors { + root /var/www/html; + allow all; + internal; +} +# Needed otherwise the image-caching directives for noblogs take precedence. +location ~* ^/__errors/(.*\.png)$ { + alias /var/www/html/__errors/$1; +} + +error_page 500 /__errors/500.html; +error_page 502 /__errors/502.html; +error_page 503 /__errors/503.html; +error_page 504 /__errors/504.html; +error_page 429 /__errors/429.html; +error_page 451 /__errors/451.html; + diff --git a/roles/nginx/templates/nginx-vhost.j2 b/roles/nginx/templates/nginx-vhost.j2 index c6fb365ceab9be480392f783cdf0162fda3eb04e..c5921637ef5dcaa7646419d1deb18400c873129c 100644 --- a/roles/nginx/templates/nginx-vhost.j2 +++ b/roles/nginx/templates/nginx-vhost.j2 @@ -35,6 +35,7 @@ server { ssl_certificate_key /etc/credentials/public/{{ endpoint.name }}.{{ domain_public[0] }}/privkey.pem; include /etc/nginx/snippets/site-limits.conf; + include /etc/nginx/snippets/custom-errors.conf; location = /favicon.ico { expires 15d;