Skip to content

Commit f140dd3

Browse files
author
Paramtamtam
committed
v1.2.0
1 parent 699cccb commit f140dd3

File tree

10 files changed

+131
-56
lines changed

10 files changed

+131
-56
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,8 @@ jobs: # Docs: <https://git.io/JvxXE>
5151
- name: Pause
5252
run: sleep 2
5353

54-
- name: Send HTTP request
54+
- name: Verify 500.html error file exists in root
5555
run: curl -sS --fail "http://127.0.0.1:8080/500.html"
56+
57+
- name: Verify root request HTTP code
58+
run: test $(curl --write-out %{http_code} --silent --output /dev/null http://127.0.0.1:8080/) -eq 404

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ All notable changes to this package will be documented in this file.
44

55
The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].
66

7+
## v1.2.0
8+
9+
### Fixed
10+
11+
- By default `nginx` in docker container returns 404 http code instead 200 when `/` requested
12+
13+
### Changed
14+
15+
- Default value for `TEMPLATE_NAME` is `ghost` now
16+
17+
### Removed
18+
19+
- Environment variable `DEFAULT_ERROR_CODE` support in docker image
20+
21+
### Added
22+
23+
- Templates `l7-light` and `l7-dark`
24+
725
## v1.1.0
826

927
### Added

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ gen: ## Generate error pages
2626
preview: ## Build docker image and start preview
2727
$(DOCKER_BIN) build -f ./Dockerfile -t $(APP_NAME):local .
2828
@printf "\n \e[30;42m %s \033[0m\n\n" 'Now open in your favorite browser <http://127.0.0.1:8081> and press CTRL+C for stopping'
29-
$(DOCKER_BIN) run --rm -i -p 8081:8080 -e "TEMPLATE_NAME=ghost" $(APP_NAME):local
29+
$(DOCKER_BIN) run --rm -i -p 8081:8080 -e "TEMPLATE_NAME=l7-light" $(APP_NAME):local
3030

3131
shell: ## Start shell into container with node
3232
$(DC_BIN) run $(DC_RUN_ARGS) app sh

README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,28 @@ $ make preview
4444

4545
## Templates
4646

47-
Name | Preview
48-
:------: | :-----:
49-
`ghost` | ![ghost](https://hsto.org/webt/zg/ul/cv/zgulcvxqzhazoebxhg8kpxla8lk.png)
47+
Name | Preview
48+
:--------: | :-----:
49+
`ghost` | ![ghost](https://hsto.org/webt/zg/ul/cv/zgulcvxqzhazoebxhg8kpxla8lk.png)
50+
`l7-light` | ![ghost](https://hsto.org/webt/xc/iq/vt/xciqvty-aoj-rchfarsjhutpjny.png)
51+
`l7-dark` | ![ghost](https://hsto.org/webt/s1/ih/yr/s1ihyrqs_y-sgraoimfhk6ypney.png)
5052

5153
## Usage
5254

5355
Generated error pages in our [docker image][link_docker_hub] permanently located in directory `/opt/html/%TEMPLATE_NAME%`. `nginx` in a container listen for `8080` (`http`) port.
5456

5557
#### Supported environment variables
5658

57-
Name | Description
58-
-------------------- | -----------
59-
`TEMPLATE_NAME` | "default" pages template _(allows to use error pages without passing theme name in URL - `http://127.0.0.1/500.html` instead `http://127.0.0.1/ghost/500.html`)_
60-
`DEFAULT_ERROR_CODE` | (`404` by default) Code with passed error code will be used as default (index) page (can be used only with `TEMPLATE_NAME` variable)
59+
Name | Description
60+
--------------- | -----------
61+
`TEMPLATE_NAME` | (`ghost` by default) "default" pages template _(allows to use error pages without passing theme name in URL - `http://127.0.0.1/500.html` instead `http://127.0.0.1/ghost/500.html`)_
6162

6263
### HTTP server for error pages serving only
6364

6465
Execute in your shell:
6566

6667
```bash
67-
$ docker run --rm -p "8082:8080" tarampampam/error-pages:1.1.0
68+
$ docker run --rm -p "8082:8080" tarampampam/error-pages:1.2.0
6869
```
6970

7071
And open in your browser `http://127.0.0.1:8082/ghost/400.html`.
@@ -105,7 +106,7 @@ FROM nginx:1.18-alpine
105106
COPY --chown=nginx \
106107
./nginx.conf /etc/nginx/conf.d/default.conf
107108
COPY --chown=nginx \
108-
--from=tarampampam/error-pages:1.1.0 \
109+
--from=tarampampam/error-pages:1.2.0 \
109110
/opt/html/ghost /usr/share/nginx/errorpages/_error-pages
110111
```
111112

@@ -120,7 +121,7 @@ version: '3.8'
120121

121122
services:
122123
error-pages:
123-
image: tarampampam/error-pages:1.1.0
124+
image: tarampampam/error-pages:1.2.0
124125
environment:
125126
TEMPLATE_NAME: ghost
126127
networks:
@@ -136,17 +137,17 @@ services:
136137
reservations:
137138
memory: 16M
138139
labels:
139-
- traefik.enable=true
140-
- traefik.docker.network=traefik-public
141-
- traefik.http.routers.error-pages-router.rule=HostRegexp(`{host:.+}`)
142-
- traefik.http.routers.error-pages-router.tls=true
143-
- traefik.http.routers.error-pages-router.priority=10
144-
- traefik.http.routers.error-pages-router.entrypoints=https
145-
- traefik.http.routers.error-pages-router.middlewares=error-pages-middleware@docker
146-
- traefik.http.services.error-pages-service.loadbalancer.server.port=8080
147-
- traefik.http.middlewares.error-pages-middleware.errors.status=400-599
148-
- traefik.http.middlewares.error-pages-middleware.errors.service=error-pages-service@docker
149-
- traefik.http.middlewares.error-pages-middleware.errors.query=/{status}.html
140+
- traefik.enable: true
141+
- traefik.docker.network: traefik-public
142+
- traefik.http.routers.error-pages-router.rule: HostRegexp(`{host:.+}`)
143+
- traefik.http.routers.error-pages-router.tls: true
144+
- traefik.http.routers.error-pages-router.priority: 10
145+
- traefik.http.routers.error-pages-router.entrypoints: https
146+
- traefik.http.routers.error-pages-router.middlewares: error-pages-middleware@docker
147+
- traefik.http.services.error-pages-service.loadbalancer.server.port: 8080
148+
- traefik.http.middlewares.error-pages-middleware.errors.status: 400-599
149+
- traefik.http.middlewares.error-pages-middleware.errors.service: error-pages-service@docker
150+
- traefik.http.middlewares.error-pages-middleware.errors.query: /{status}.html
150151

151152
networks:
152153
traefik-public:

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
{
44
"name": "ghost",
55
"path": "./templates/ghost.html"
6+
},
7+
{
8+
"name": "l7-light",
9+
"path": "./templates/l7-light.html"
10+
},
11+
{
12+
"name": "l7-dark",
13+
"path": "./templates/l7-dark.html"
614
}
715
],
816
"output": {

docker/docker-entrypoint.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env sh
22
set -e
33

4-
TEMPLATE_NAME=${TEMPLATE_NAME:-} # string|empty
5-
DEFAULT_ERROR_CODE=${DEFAULT_ERROR_CODE:-404} # numeric
4+
TEMPLATE_NAME=${TEMPLATE_NAME:-ghost} # string|empty
65

76
if [ -n "$TEMPLATE_NAME" ]; then
87
echo "$0: set pages for template '$TEMPLATE_NAME' as default (make accessible in root directory)";
@@ -13,13 +12,9 @@ if [ -n "$TEMPLATE_NAME" ]; then
1312

1413
ln -f -s "/opt/html/$TEMPLATE_NAME/"* /opt/html;
1514

16-
if [ -L "/opt/html/$DEFAULT_ERROR_CODE.html" ]; then
17-
echo "$0: set page with error code '$DEFAULT_ERROR_CODE' as default (index) page";
18-
19-
cp -f "/opt/html/$DEFAULT_ERROR_CODE.html" /opt/html/index.html;
20-
else
21-
(>&2 echo "$0: cannot set page with error code '$DEFAULT_ERROR_CODE' as default (index) page!");
22-
fi;
15+
# next directory is required for easy nginx `error_page` usage
16+
mkdir /opt/html/nginx-error-pages;
17+
ln -f -s "/opt/html/$TEMPLATE_NAME/"* /opt/html/nginx-error-pages;
2318
fi;
2419

2520
exec "$@"

docker/nginx-server.conf

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@ server {
22
listen 8080;
33
server_name _;
44

5+
index index.html index.htm;
6+
root /opt/html;
7+
8+
error_page 400 /nginx-error-pages/400.html;
9+
error_page 401 /nginx-error-pages/401.html;
10+
error_page 403 /nginx-error-pages/403.html;
11+
error_page 404 /nginx-error-pages/404.html;
12+
error_page 500 /nginx-error-pages/500.html;
13+
error_page 502 /nginx-error-pages/502.html;
14+
15+
location ^~ /nginx-error-pages/ {
16+
internal;
17+
root /opt/html;
18+
}
19+
520
location / {
6-
root /opt/html;
7-
index index.html index.htm;
21+
try_files $uri =404;
822
}
923
}

static/index.html

Lines changed: 0 additions & 22 deletions
This file was deleted.

templates/l7-dark.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta name="robots" content="noindex, nofollow" />
7+
<title>{{ message }}</title>
8+
<link rel="dns-prefetch" href="//fonts.gstatic.com">
9+
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
10+
<style>
11+
html,body {background-color: #222526;color:#fff;font-family:'Nunito',sans-serif;font-weight:100;height:100vh;margin:0}
12+
.full-height {height:100vh}
13+
.flex-center {align-items:center;display:flex;justify-content:center}
14+
.position-ref {position:relative}
15+
.code {border-right:2px solid;font-size:26px;padding:0 10px 0 15px;text-align:center}
16+
.message {font-size:18px;text-align:center;padding:10px}
17+
</style>
18+
</head>
19+
<body>
20+
<div class="flex-center position-ref full-height">
21+
<div class="code">
22+
{{ code }}
23+
</div>
24+
<div class="message">
25+
{{ message }}
26+
</div>
27+
</div>
28+
</body>
29+
</html>

templates/l7-light.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta name="robots" content="noindex, nofollow" />
7+
<title>{{ message }}</title>
8+
<link rel="dns-prefetch" href="//fonts.gstatic.com">
9+
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
10+
<style>
11+
html,body {background-color:#fff;color:#636b6f;font-family:'Nunito',sans-serif;font-weight:100;height:100vh;margin:0}
12+
.full-height {height:100vh}
13+
.flex-center {align-items:center;display:flex;justify-content:center}
14+
.position-ref {position:relative}
15+
.code {border-right:2px solid;font-size:26px;padding:0 10px 0 15px;text-align:center}
16+
.message {font-size:18px;text-align:center;padding:10px}
17+
</style>
18+
</head>
19+
<body>
20+
<div class="flex-center position-ref full-height">
21+
<div class="code">
22+
{{ code }}
23+
</div>
24+
<div class="message">
25+
{{ message }}
26+
</div>
27+
</div>
28+
</body>
29+
</html>

0 commit comments

Comments
 (0)