40xda 中文文档教程

发布于 9年前 浏览 38 项目主页 更新于 3年前

40x-da

漂亮的 40 倍错误页面显示 DeviantArt 的每日偏差

40x-da 示例页面 此示例显示 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 as status 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.envprocess.argv); [ ] 添加消息配置文件以自定义显示的消息。

欢迎投稿!

40x-da

Beautiful 40x error pages showing DeviantArt's daily deviations.

40x-da example page 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 40xand 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 as status 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 !

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文