You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+89-29Lines changed: 89 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,23 @@
1
1
[nginx](#nginx-integration) |
2
-
[expressjs](#expressjs-integration) |
3
2
[Apache HTTPD](#apache-httpd-integration) |
4
3
[Lighttpd](#lighttpd-integration) |
4
+
[express.js](#expressjs-integration) |
5
+
[koa.js](#koajs-integration) |
5
6
[Customization](#customization)
6
7
7
8
# Simple HttpErrorPages #
8
-
Simple HTTP Error Page Generator. Create a bunch of custom error pages - suitable to use with Lighttpd, Nginx, expressjs, Apache-Httpd or any other Webserver.
9
+
Simple HTTP Error Page Generator. Create a bunch of custom error pages - suitable to use with Lighttpd, Nginx, expressjs, koajs ,Apache-Httpd or any other Webserver.
[Apache Httpd 2.x](http://httpd.apache.org/) supports custom error-pages using multiple [ErrorDocument](http://httpd.apache.org/docs/2.4/mod/core.html#errordocument) directives.
86
+
87
+
File: `httpd.conf` or `.htaccess`
88
+
89
+
Example - assumes HttpErrorPages are located into your **document root**`/var/www/...docroot../ErrorPages`.
90
+
91
+
```ApacheConf
92
+
ErrorDocument 400 /ErrorPages/HTTP400.html
93
+
ErrorDocument 401 /ErrorPages/HTTP401.html
94
+
ErrorDocument 403 /ErrorPages/HTTP403.html
95
+
ErrorDocument 404 /ErrorPages/HTTP404.html
96
+
ErrorDocument 500 /ErrorPages/HTTP500.html
97
+
ErrorDocument 501 /ErrorPages/HTTP501.html
98
+
ErrorDocument 502 /ErrorPages/HTTP502.html
99
+
ErrorDocument 503 /ErrorPages/HTTP503.html
100
+
```
101
+
102
+
## Lighttpd Integration ##
103
+
104
+
[Lighttpd](http://www.lighttpd.net/) supports custom error-pages using the [server.errorfile-prefix](http://redmine.lighttpd.net/projects/lighttpd/wiki/Server_errorfile-prefixDetails) directive.
105
+
106
+
File: `lighttpd.conf`
107
+
108
+
Example - assumes HttpErrorPages are located into `/var/www/ErrorPages/`.
*`lang` - language definition which should be used (available in the `i18n/` directory). default **en_US**
141
180
142
-
## Apache Httpd Integration ##
143
-
[Apache Httpd 2.x](http://httpd.apache.org/) supports custom error-pages using multiple [ErrorDocument](http://httpd.apache.org/docs/2.4/mod/core.html#errordocument) directives.
181
+
## koajs Integration ##
144
182
145
-
File: `httpd.conf` or `.htaccess`
183
+
HttpErrorPages are available as NPM-Package - just install `http-error-pages` via **npm/yarn**
146
184
147
-
Example - assumes HttpErrorPages are located into your **document root**`/var/www/...docroot../ErrorPages`.
185
+
**Installation**
148
186
149
-
```ApacheConf
150
-
ErrorDocument 400 /ErrorPages/HTTP400.html
151
-
ErrorDocument 401 /ErrorPages/HTTP401.html
152
-
ErrorDocument 403 /ErrorPages/HTTP403.html
153
-
ErrorDocument 404 /ErrorPages/HTTP404.html
154
-
ErrorDocument 500 /ErrorPages/HTTP500.html
155
-
ErrorDocument 501 /ErrorPages/HTTP501.html
156
-
ErrorDocument 502 /ErrorPages/HTTP502.html
157
-
ErrorDocument 503 /ErrorPages/HTTP503.html
187
+
```terminal
188
+
yarn add http-error-pages
158
189
```
159
190
160
-
## Lighttpd Integration ##
161
-
162
-
[Lighttpd](http://www.lighttpd.net/) supports custom error-pages using the [server.errorfile-prefix](http://redmine.lighttpd.net/projects/lighttpd/wiki/Server_errorfile-prefixDetails) directive.
191
+
**Example**
163
192
164
-
File: `lighttpd.conf`
193
+
A ready-to-use example can be found in [examples/koa.js](exmaples/koa.js).
194
+
Keep in mind that the following example has to be executed within an async context!
165
195
166
-
Example - assumes HttpErrorPages are located into `/var/www/ErrorPages/`.
196
+
```js
197
+
const_koa=require('koa');
198
+
const_webapp=new_koa();
199
+
const_httpErrorPages=require('http-error-pages');
200
+
201
+
// use http error pages handler (INITIAL statement!)
202
+
// because of the asynchronous file-loaders, wait until it has been executed - it returns an async handler
*`lang` - language definition which should be used (available in the `i18n/` directory). default **en_US**
230
+
231
+
172
232
## Customization ##
173
233
174
234
First of all, [clone](https://github.com/AndiDittrich/HttpErrorPages.git)
@@ -186,7 +246,7 @@ yarn install
186
246
npm install
187
247
```
188
248
189
-
To customize the pages, you can edit any of the template files and **finally run the generator-script**.
249
+
To customize the pages, you can edit any of the [template files](assets/) and **finally run the generator-script**.
190
250
All generated html files are located into the `dist/` directory by default.
191
251
192
252
If you wan't to add custom pages/additional error-codes, just put a new entry into the `i18n/pages-en_US.json` file (its recommended to copy the file).
<divclass="cover"><h1>Webservice currently unavailable <small>Error 500</small></h1><pclass="lead">An unexpected condition was encountered.
11
-
Our service team has been dispatched to bring it back online.</p></div>
10
+
<divclass="cover"><h1>Webservice currently unavailable <small>Error 500</small></h1><pclass="lead">An unexpected condition was encountered.<br/>Our service team has been dispatched to bring it back online.</p></div>
<divclass="cover"><h1>Webservice currently unavailable <small>Error 502</small></h1><pclass="lead">We've got some trouble with our backend upstream cluster.
11
-
Our service team has been dispatched to bring it back online.</p></div>
10
+
<divclass="cover"><h1>Webservice currently unavailable <small>Error 502</small></h1><pclass="lead">We've got some trouble with our backend upstream cluster.<br/>Our service team has been dispatched to bring it back online.</p></div>
<divclass="cover"><h1>Webservice currently unavailable <small>Error 503</small></h1><pclass="lead">We've got some trouble with our backend upstream cluster.
11
-
Our service team has been dispatched to bring it back online.</p></div>
10
+
<divclass="cover"><h1>Webservice currently unavailable <small>Error 503</small></h1><pclass="lead">We've got some trouble with our backend upstream cluster.<br/>Our service team has been dispatched to bring it back online.</p></div>
0 commit comments