Skip to content

Commit

Permalink
Allow to configure the path to the custom error pages
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Dec 23, 2014
1 parent f2c53f0 commit c3fef07
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Basic Hipache configuration is described in a json file. For example:
"accessLog": "/var/log/hipache_access.log",
"workers": 5,
"maxSockets": 100,
"deadBackendTTL": 30
"deadBackendTTL": 30,
"staticDir": null
},
"http": {
"port": 80,
Expand All @@ -69,6 +70,7 @@ master process does not serve any request. Defaults to `10` if not specified.
* __server.maxSockets__: The maximum number of sockets which can be opened on each backend (per worker). Defaults to `100` if not specified.
* __server.deadBackendTTL__: The number of seconds a backend is flagged as
'dead' before retrying to proxy another request to it (doesn't apply if you are using a third-party health checker). Defaults to `30`.
* __server.staticDir__: The absolute path of the directory containing your custom static error pages. Default value `null` means it uses Hipache's pages.
* __http__: specifies on which ips/ports hipache will listen for http traffic. By default, hipache listens only on 127.0.0.1:80
* __http.port__: port to listen to for http. Defaults to `80`.
* __http.bind__: IPv4 (or IPv6) address, or addresses to listen to. You can specify a single ip, an array of ips, or an array of objects `{address: IP, port: PORT}` if you want to use a specific port on a specific ip. Defaults to `127.0.0.1`.
Expand Down
3 changes: 2 additions & 1 deletion config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"tcpTimeout": 30,
"retryOnError": 3,
"deadBackendOn500": true,
"httpKeepAlive": false
"httpKeepAlive": false,
"staticDir": null
},
"https": {
"port": 443,
Expand Down
3 changes: 2 additions & 1 deletion lib/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
retryOnError: 3,
accessLog: "/var/log/hipache/access.log",
httpKeepAlive: false,
deadBackendOn500: true
deadBackendOn500: true,
staticDir: null
}
};

Expand Down
4 changes: 3 additions & 1 deletion lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ Worker.prototype.runServer = function (config) {
return null;
};

var staticDir = config.server.staticDir || [ rootDir, 'static' ].join('/');

var errorMessage = function (res, message, code) {
// Flag the Response to know that it's an internal error message
res.errorMessage = true;
Expand All @@ -187,7 +189,7 @@ Worker.prototype.runServer = function (config) {
code = isNaN(code) ? 400 : parseInt(code, 10);

var staticPath = function (name) {
return rootDir + '/static/error_' + name + '.html';
return [ staticDir, '/', 'error_', name, '.html' ].join('');
};

var serveFile = function (filePath) {
Expand Down

0 comments on commit c3fef07

Please sign in to comment.