40xda 中文文档教程
40x-da
漂亮的 40 倍错误页面显示 DeviantArt 的每日偏差。
此示例显示 Thoughts Yavannas 作者 kimberly80.
40x-da 作为一个单独的网络服务器工作,为 http 错误页面(400、401、402,因此 40x)提供 html 内容
甚至 50 倍……)。 它并不意味着在互联网上公开可用(为什么你会给你用户访问一堆 40x 和 50x 页面的权限?)。
Installation
从此处获取 DeviantArt API 访问权限。
克隆这个 repo 并安装 npm 依赖项:
$ cd /path/to/install/directory
$ git clone https://github.com/as0n/40x-da.git
$ cd 40x-da
$ npm install
运行服务器:(
$ DA_CLIENT_ID=0123 DA_CLIENT_SECRET=my_secret npm start
也许你应该使用类似 forever 的东西来妖魔化这个过程)。
配置面向 Internet 的 Web 服务器以将 40x 和 50x 错误页面代理到 40x-da 服务器。 例如,在 nginx 上,您可以执行以下操作:
server {
...
error_page 403 /errors/403
error_page 404 /errors/404
error_page 500 /errors/500
location ~/errors/(\d+) {
proxy_pass http://127.0.0.1:8004/$1;
allow all;
}
...
}
Features
- Every http code is valid : you can GET any url like
http://40x-da-server/<status>
as long asstatus
is a numeric value. - Custom error messages : message can be set via query parameters like so :
http://40x-da-server/404?message=These are not the droids you are looking for
. - Listening port is customizable via the
PORT
environment variable. - 40xda is compatible with heroku !
Todo
[X] 添加监听端口参数(通过 process.env
或 process.argv
); [ ] 添加消息配置文件以自定义显示的消息。
欢迎投稿!
40x-da
Beautiful 40x error pages showing DeviantArt's daily deviations.
This example shows Thoughts Yavannas by kimberly80.
40x-da works as a separate web-server delivering html content for http error pages (400, 401, 402, hence 40x
and even 50x …). It is not meant to be publicly available on the internet (why would you give you user access to a bunch of 40x and 50x pages ?).
Installation
Get a DeviantArt API access from here.
Clone this repo and install npm dependencies :
$ cd /path/to/install/directory
$ git clone https://github.com/as0n/40x-da.git
$ cd 40x-da
$ npm install
Run the server :
$ DA_CLIENT_ID=0123 DA_CLIENT_SECRET=my_secret npm start
(maybe you should demonize the process using something like forever).
Configure you internet-facing webserver to proxy 40x and 50x error pages to the 40x-da server. For instance on nginx you could do something like :
server {
...
error_page 403 /errors/403
error_page 404 /errors/404
error_page 500 /errors/500
location ~/errors/(\d+) {
proxy_pass http://127.0.0.1:8004/$1;
allow all;
}
...
}
Features
- Every http code is valid : you can GET any url like
http://40x-da-server/<status>
as long asstatus
is a numeric value. - Custom error messages : message can be set via query parameters like so :
http://40x-da-server/404?message=These are not the droids you are looking for
. - Listening port is customizable via the
PORT
environment variable. - 40xda is compatible with heroku !
Todo
[X] Add listening port parameter (either via process.env
or process.argv
); [ ] Add message configuration file to customize displayed messages.
Contributions welcomed !