Compare commits

...

9 Commits

Author SHA1 Message Date
a55ec08eef Release action fixed 2021-03-04 11:37:03 +05:00
7957d16c0f New template "shuffle" was added (#5) 2021-03-04 11:28:48 +05:00
80b2544f36 Fix issue #3 2020-08-31 14:03:48 +05:00
090767ba6b Readme file updated 2020-07-16 15:20:29 +05:00
a040c913e7 Set server_tokens off; in nginx server configuration 2020-07-16 15:19:44 +05:00
5ab113ba1a Update README.md 2020-07-16 12:15:57 +05:00
ea46e9f738 Update README.md 2020-07-16 12:14:34 +05:00
aeb6018a57 Update README.md 2020-07-14 15:05:36 +05:00
158856bebd Add 418 error (#2)
* Update config.json

Add 418 error

* Update CHANGELOG.md
2020-07-10 19:38:26 +05:00
8 changed files with 159 additions and 35 deletions

View File

@ -7,7 +7,7 @@ on:
jobs:
demo:
name: Update demonstration, hosted on github pages
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2
@ -17,9 +17,6 @@ jobs:
with:
node-version: 12
- name: Generate version value
run: echo "::set-env name=PACKAGE_VERSION::${GITHUB_REF##*/v}"
- uses: actions/cache@v2
with:
path: '**/node_modules'
@ -67,24 +64,25 @@ jobs:
docker-image:
name: Build docker image
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Generate image tag value
run: echo "::set-env name=IMAGE_TAG::${GITHUB_REF##*/[vV]}" # `/refs/tags/v1.2.3` -> `1.2.3`
- name: Generate builder values
id: values
run: echo "::set-output name=version::${GITHUB_REF##*/[vV]}" # `/refs/tags/v1.2.3` -> `1.2.3`
- name: Make docker login
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_LOGIN }}" --password-stdin &> /dev/null
- name: Build image
run: docker build --tag "tarampampam/error-pages:${IMAGE_TAG}" --tag "tarampampam/error-pages:latest" -f ./Dockerfile .
run: docker build --tag "tarampampam/error-pages:${{ steps.values.outputs.version }}" --tag "tarampampam/error-pages:latest" -f ./Dockerfile .
- name: Push version image
run: docker push "tarampampam/error-pages:${IMAGE_TAG}"
run: docker push "tarampampam/error-pages:${{ steps.values.outputs.version }}"
- name: Push latest image
run: docker push "tarampampam/error-pages:latest"

View File

@ -11,7 +11,7 @@ on:
jobs: # Docs: <https://git.io/JvxXE>
generate:
name: Try to run generator
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2
@ -37,7 +37,7 @@ jobs: # Docs: <https://git.io/JvxXE>
docker-build:
name: Build docker image
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2

View File

@ -4,6 +4,29 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].
## v1.4.0
### Added
- Template `shuffle` [#4]
[#3]:https://github.com/tarampampam/error-pages/issues/4
## v1.3.1
### Fixed
- `can't create directory '/opt/html/nginx-error-pages'` error [#3]
[#3]:https://github.com/tarampampam/error-pages/issues/3
## v1.3.0
### Added
- `418` status code error page
- Set `server_tokens off;` in `nginx` server configuration
## v1.2.0
### Fixed

View File

@ -47,8 +47,9 @@ $ make preview
Name | Preview
:--------: | :-----:
`ghost` | ![ghost](https://hsto.org/webt/zg/ul/cv/zgulcvxqzhazoebxhg8kpxla8lk.png)
`l7-light` | ![ghost](https://hsto.org/webt/xc/iq/vt/xciqvty-aoj-rchfarsjhutpjny.png)
`l7-dark` | ![ghost](https://hsto.org/webt/s1/ih/yr/s1ihyrqs_y-sgraoimfhk6ypney.png)
`l7-light` | ![l7-light](https://hsto.org/webt/xc/iq/vt/xciqvty-aoj-rchfarsjhutpjny.png)
`l7-dark` | ![l7-dark](https://hsto.org/webt/s1/ih/yr/s1ihyrqs_y-sgraoimfhk6ypney.png)
`shuffle` | ![shuffle](https://habrastorage.org/webt/ck/gk/lj/ckgkljezwegq5rbcocalykfgv3u.png)
## Usage
@ -65,7 +66,7 @@ Name | Description
Execute in your shell:
```bash
$ docker run --rm -p "8082:8080" tarampampam/error-pages:1.2.0
$ docker run --rm -p "8082:8080" tarampampam/error-pages:1.4.0
```
And open in your browser `http://127.0.0.1:8082/ghost/400.html`.
@ -106,7 +107,7 @@ FROM nginx:1.18-alpine
COPY --chown=nginx \
./nginx.conf /etc/nginx/conf.d/default.conf
COPY --chown=nginx \
--from=tarampampam/error-pages:1.2.0 \
--from=tarampampam/error-pages:1.4.0 \
/opt/html/ghost /usr/share/nginx/errorpages/_error-pages
```
@ -117,37 +118,52 @@ COPY --chown=nginx \
Simple traefik (tested on `v2.2.1`) service configuration for usage in [docker swarm][link_swarm] (**change with your needs**):
```yaml
version: '3.8'
version: '3.4'
services:
error-pages:
image: tarampampam/error-pages:1.2.0
image: tarampampam/error-pages:1.4.0
environment:
TEMPLATE_NAME: ghost
TEMPLATE_NAME: l7-dark
networks:
- traefik-public
deploy:
placement:
constraints:
- node.role == worker
max_replicas_per_node: 1
resources:
limits:
memory: 32M
reservations:
memory: 16M
labels:
- traefik.enable: true
- traefik.docker.network: traefik-public
- traefik.http.routers.error-pages-router.rule: HostRegexp(`{host:.+}`)
- traefik.http.routers.error-pages-router.tls: true
- traefik.http.routers.error-pages-router.priority: 10
- traefik.http.routers.error-pages-router.entrypoints: https
- traefik.http.routers.error-pages-router.middlewares: error-pages-middleware@docker
- traefik.http.services.error-pages-service.loadbalancer.server.port: 8080
- traefik.http.middlewares.error-pages-middleware.errors.status: 400-599
- traefik.http.middlewares.error-pages-middleware.errors.service: error-pages-service@docker
- traefik.http.middlewares.error-pages-middleware.errors.query: /{status}.html
traefik.enable: 'true'
traefik.docker.network: traefik-public
# use as "fallback" for any non-registered services (with priority below normal)
traefik.http.routers.error-pages-router.rule: HostRegexp(`{host:.+}`)
traefik.http.routers.error-pages-router.priority: 10
# should say that all of your services work on https
traefik.http.routers.error-pages-router.tls: 'true'
traefik.http.routers.error-pages-router.entrypoints: https
traefik.http.routers.error-pages-router.middlewares: error-pages-middleware@docker
traefik.http.services.error-pages-service.loadbalancer.server.port: 8080
# "errors" middleware settings
traefik.http.middlewares.error-pages-middleware.errors.status: 400-599
traefik.http.middlewares.error-pages-middleware.errors.service: error-pages-service@docker
traefik.http.middlewares.error-pages-middleware.errors.query: /{status}.html
any-another-http-service:
image: nginx:alpine
networks:
- traefik-public
deploy:
placement:
constraints:
- node.role == worker
labels:
traefik.enable: 'true'
traefik.docker.network: traefik-public
traefik.http.routers.another-service.rule: Host(`subdomain.example.com`)
traefik.http.routers.another-service.tls: 'true'
traefik.http.routers.another-service.entrypoints: https
# next line is important
traefik.http.routers.another-service.middlewares: error-pages-middleware@docker
traefik.http.services.another-service.loadbalancer.server.port: 80
networks:
traefik-public:

View File

@ -11,6 +11,10 @@
{
"name": "l7-dark",
"path": "./templates/l7-dark.html"
},
{
"name": "shuffle",
"path": "./templates/shuffle.html"
}
],
"output": {
@ -82,6 +86,11 @@
"message": "Requested Range Not Satisfiable",
"description": "The requested byte range is not available and is out of bounds"
},
{
"code": 418,
"message": "I'm a teapot",
"description": "Attempt to brew coffee with a teapot is not supported"
},
{
"code": 429,
"message": "Too Many Requests",

View File

@ -12,6 +12,11 @@ if [ -n "$TEMPLATE_NAME" ]; then
ln -f -s "/opt/html/$TEMPLATE_NAME/"* /opt/html;
# on `docker restart` next directory keep existing: <https://github.com/tarampampam/error-pages/issues/3>
if [ -d /opt/html/nginx-error-pages ]; then
rm -Rf /opt/html/nginx-error-pages;
fi;
# next directory is required for easy nginx `error_page` usage
mkdir /opt/html/nginx-error-pages;
ln -f -s "/opt/html/$TEMPLATE_NAME/"* /opt/html/nginx-error-pages;

View File

@ -2,6 +2,8 @@ server {
listen 8080;
server_name _;
server_tokens off;
index index.html index.htm;
root /opt/html;

71
templates/shuffle.html Normal file
View File

@ -0,0 +1,71 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{ code }} - {{ message }}</title>
<style>
html, body {
margin: 0;
background-color: #222;
color: #aaa;
font-family: 'Hack', monospace
}
.full-height {
height: 100vh
}
.flex-center {
align-items: center;
display: flex;
justify-content: center
}
#error_text {
font-size: 2em
}
</style>
</head>
<body>
<div class="flex-center full-height">
<span id="error_text">{{ code }}: {{ message }}</span>
</div>
<script>
'use strict';
const $errorText = document.getElementById('error_text'),
text = $errorText.innerText,
characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=+<>,./?[{()}]!@#$%^&*~`\|'.split('');
let progress = 0;
const scrambleInterval = window.setInterval(function () {
let newText = text;
for (let i = 0; i < text.length; i++) {
if (i >= progress) {
newText = newText.substr(0, i) +
characters[Math.round(Math.random() * (characters.length - 1))] +
newText.substr(i + 1);
}
}
$errorText.innerText = newText;
}, 800 / 60);
window.setTimeout(function () {
let revealInterval = window.setInterval(function () {
if (progress < text.length) {
progress++;
} else {
window.clearInterval(revealInterval);
window.clearInterval(scrambleInterval);
}
}, 70);
}, 350);
</script>
</body>
</html>