Merge branch 'master' of https://github.com/AndiDittrich/HttpErrorPages
This commit is contained in:
commit
cd357480ca
5 changed files with 137 additions and 23 deletions
63
README.md
63
README.md
|
@ -37,27 +37,37 @@ wget https://raw.githubusercontent.com/AndiDittrich/HttpErrorPages/master/dist/p
|
|||
|
||||
[NGINX](http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page) supports custom error-pages using multiple `error_page` directives.
|
||||
|
||||
File: `default.conf`
|
||||
File: [`default.conf`](https://www.nginx.com/resources/wiki/start/topics/examples/full/)
|
||||
|
||||
Example - assumes HttpErrorPages are located into `/var/www/ErrorPages/`.
|
||||
Example - assumes HttpErrorPages are located into `/var/ErrorPages/`.
|
||||
|
||||
```nginx
|
||||
# add one directive for each http status code
|
||||
error_page 400 /ErrorPages/HTTP400.html;
|
||||
error_page 401 /ErrorPages/HTTP401.html;
|
||||
error_page 402 /ErrorPages/HTTP402.html;
|
||||
error_page 403 /ErrorPages/HTTP403.html;
|
||||
error_page 404 /ErrorPages/HTTP404.html;
|
||||
error_page 500 /ErrorPages/HTTP500.html;
|
||||
error_page 501 /ErrorPages/HTTP501.html;
|
||||
error_page 502 /ErrorPages/HTTP502.html;
|
||||
error_page 503 /ErrorPages/HTTP503.html;
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
root /var/www;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
|
||||
# add one directive for each http status code
|
||||
error_page 400 /ErrorPages/HTTP400.html;
|
||||
error_page 401 /ErrorPages/HTTP401.html;
|
||||
error_page 402 /ErrorPages/HTTP402.html;
|
||||
error_page 403 /ErrorPages/HTTP403.html;
|
||||
error_page 404 /ErrorPages/HTTP404.html;
|
||||
error_page 500 /ErrorPages/HTTP500.html;
|
||||
error_page 501 /ErrorPages/HTTP501.html;
|
||||
error_page 502 /ErrorPages/HTTP502.html;
|
||||
error_page 503 /ErrorPages/HTTP503.html;
|
||||
}
|
||||
|
||||
# redirect the virtual ErrorPages path the real path
|
||||
location /ErrorPages/ {
|
||||
alias /var/www/ErrorPages/;
|
||||
internal;
|
||||
}
|
||||
# redirect the virtual ErrorPages path the real path
|
||||
location /ErrorPages/ {
|
||||
alias /var/ErrorPages/;
|
||||
internal;
|
||||
}
|
||||
```
|
||||
|
||||
## expressjs Integration ##
|
||||
|
@ -147,22 +157,33 @@ Custom Error-Codes used by e.g. CloudFlare
|
|||
```
|
||||
|
||||
### Build/Generator ###
|
||||
* Install packages using npm or yarn and have php in your executable path*
|
||||
Used Naming-Scheme: `HTTP#CODE#.html` (customizable by editing the `config.ini`)
|
||||
To generate the static html pages, run the `generator.php` script:
|
||||
|
||||
```shell
|
||||
php generator.php
|
||||
npm run generate-php
|
||||
```
|
||||
|
||||
All generated html files are located into the `dist/` directory by default.
|
||||
|
||||
### Compile LESS Files ###
|
||||
To rebuild the LESS files run the **ANT** build script (requires lessc in your path):
|
||||
To rebuild the LESS files run the :
|
||||
|
||||
```shell
|
||||
ant css
|
||||
npm run generate-css
|
||||
```
|
||||
|
||||
### Build all ###
|
||||
|
||||
```shell
|
||||
npm run generate
|
||||
```
|
||||
|
||||
|
||||
### Less CSS ###
|
||||
|
||||
Modify the `assets/Layout.less` to make your own design styles (Make sure to run build scripts after editing the files)
|
||||
|
||||
### Configuration ###
|
||||
|
||||
|
@ -186,4 +207,4 @@ footer = "Technical Contact: <a href="mailto:x@example.com">x@example.com</a>"
|
|||
```
|
||||
|
||||
## License ##
|
||||
HttpErrorsPages is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT) - your're welcome to contribute
|
||||
HttpErrorsPages is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT) - your're welcome to contribute
|
||||
|
|
|
@ -21,8 +21,25 @@ if (isset($argv[1])){
|
|||
// load config
|
||||
$config = parse_ini_file($configFilename, false);
|
||||
|
||||
// load pages
|
||||
$pages = require('pages.php');
|
||||
//default language
|
||||
$language = 'en_US';
|
||||
|
||||
if (isset($argv[2])) {
|
||||
$language = $argv[2];
|
||||
}
|
||||
|
||||
//Internationalization
|
||||
switch($language) {
|
||||
case 'pt_BR':
|
||||
$pages = require('pages-pt_BR.php');
|
||||
break;
|
||||
case 'en_US':
|
||||
$pages = require('pages-en_US.php');
|
||||
break;
|
||||
default:
|
||||
$pages = require('pages-en_US.php');
|
||||
break;
|
||||
}
|
||||
|
||||
// store pages as json data
|
||||
file_put_contents('dist/pages.json', json_encode($pages));
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
"name": "http-error-pages",
|
||||
"version": "0.5.2",
|
||||
"description": "Simple HTTP Error Pages for expressjs",
|
||||
"scripts":{
|
||||
"generate-css":"lessc assets/Layout.less assets/Layout.css",
|
||||
"generate-html":"php generator.php",
|
||||
"generate": "npm run generate-css && npm run generate-html"
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"https",
|
||||
|
@ -29,5 +34,8 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"express": "^4.15.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"less": "^2.7.3"
|
||||
}
|
||||
}
|
||||
|
|
68
pages-pt_BR.php
Normal file
68
pages-pt_BR.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
return array (
|
||||
|
||||
// STANDARD ERROR CODES
|
||||
// =======================================================
|
||||
'400' => array (
|
||||
'title' => 'Requisição inválida',
|
||||
'message' => 'Oops! Não conseguimos processar a requisição.'
|
||||
),
|
||||
'401' => array (
|
||||
'title' => 'Não Autorizado',
|
||||
'message' => 'Oops! O recurso requer uma autenticação.'
|
||||
),
|
||||
'403' => array (
|
||||
'title' => 'Acesso Negado',
|
||||
'message' => 'Oops! O recurso requer uma autenticação.'
|
||||
),
|
||||
|
||||
// http 404 not found
|
||||
'404' => array (
|
||||
'title' => 'Página Não Encontrada',
|
||||
'message'=>'Oops! Não conseguimos encontrar a página que você estava procurando.'
|
||||
),
|
||||
|
||||
// internal server error
|
||||
'500' => array (
|
||||
'title' => 'Webservice Atualmente Não Disponível',
|
||||
'message' => "Uma condição inesperada foi encontrada.\nNosso time de serviços está trabalhando para deixar isso online novamente."
|
||||
),
|
||||
|
||||
// unknown http method
|
||||
'501' => array (
|
||||
'title' => 'Não implementado',
|
||||
'message' => 'Oops! O Webserver não conseguiu reconhecer o método solicitado'
|
||||
),
|
||||
|
||||
// http proxy forward error
|
||||
'502' => array (
|
||||
'title' => 'Webservice atualmente indisponível',
|
||||
'message' => "Nós tivemos alguns problema com o nosso backend. Nosso time de serviços está trabalhando para deixar isso online novamente."
|
||||
),
|
||||
|
||||
// webserver service error
|
||||
'503' => array (
|
||||
'title' => 'Webservice atualmente indisponível',
|
||||
'message' => "Nós tivemos alguns problema com o nosso backend. Nosso time de serviços está trabalhando para deixar isso online novamente."
|
||||
),
|
||||
|
||||
// CUSTOM ERROR CODES
|
||||
// =======================================================
|
||||
// webserver origin error
|
||||
'520' => array(
|
||||
'title' => 'Origin Error - Host Desconhecido',
|
||||
'message' => 'O hostname requisitado não é roteado. Use apenas hostnames para acessar recursos.'
|
||||
),
|
||||
|
||||
// webserver down error
|
||||
'521' => array (
|
||||
'title' => 'Webservice atualmente indisponível',
|
||||
'message' => "Nós tivemos alguns problema com o nosso backend. Nosso time de serviços está trabalhando para deixar isso online novamente."
|
||||
),
|
||||
|
||||
// maintenance
|
||||
'533' => array(
|
||||
'title' => 'Estamos em manutenção',
|
||||
'message' => "O site está offline para manutenção.\nNosso time está trabalhando para reestabelecer o serviço em breve."
|
||||
)
|
||||
);
|
Loading…
Add table
Reference in a new issue