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
+54-9Lines changed: 54 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,60 @@
1
-
create-servers
2
-
==============
1
+
# create-servers
3
2
4
3
Create an http AND/OR an https server and call the same request handler.
5
4
6
-
*NOTE on Security*
5
+
## Usage
6
+
7
+
The `create-servers` module exports a function that takes a config object and
8
+
a node-style callback. The config object must have at minimum an `http` or
9
+
`https` property (or both). The following config properties are supported:
10
+
11
+
| Property | Description |
12
+
|---------------------------|-------------|
13
+
|`handler`| Request handler to be used for any server, unless overridden specifically with `http.handler` or `https.handler`. |
14
+
|`timeout`| Socket timeout in milliseconds for any server, unless overridden with `http.timeout` or `https.timeout`. Defaults to the node default of 2 minutes. |
15
+
|`http`| Optional. If present, an HTTP server is started. This can be an object or a number. If it's a number, it's used as the TCP port for an HTTP server. |
16
+
|`http.port`| TCP port for the HTTP server. Defaults to `80`. |
17
+
|`http.host`| The address the HTTP server is bound to. Defaults to `::` or `0.0.0.0`. |
18
+
|`http.timeout`| Socket timeout in milliseconds for the server. If unspecified, the top-level `timeout` configuration is used. |
19
+
|`http.handler`| Handler for HTTP requests. If you want to share a handler with all servers, use a top-level `handler` config property instead. |
20
+
|`https`| Optional object. If present, an HTTPS server is started. |
21
+
|`https.port`| TCP port for the HTTPS server. Defaults to `443`. |
22
+
|`https.host`| The address the HTTPS server is bound to. Defaults to `::` or `0.0.0.0`. |
23
+
|`https.timeout`| Socket timeout in milliseconds for the server. If unspecified, the top-level `timeout` configuration is used. |
24
+
|`https.ciphers`| Defaults to a [default cipher suite](#note-on-security). To customize, either supply a colon-separated string or array of strings for the ciphers you want the server to support. |
25
+
|`https.honorCipherOrder`| If true, prefer the server's specified cipher order instead of the client's. Defaults to `false`. |
26
+
|`https.root`| Root directory for certificate/key files. See [Certificate normalization](#certificate-normalization) for more details. |
27
+
|`https.key`| PEM/file path for the server's private key. See [Certificate normalization](#certificate-normalization) for more details. |
28
+
|`https.cert`| PEM/file path(s) for the server's certificate. See [Certificate normalization](#certificate-normalization) for more details. |
29
+
|`https.ca`| Cert or array of certs specifying trusted authorities for peer certificates. Only required if your server accepts client certificate connections signed by authorities that are not trusted by default. See [Certificate normalization](#certificate-normalization) for more details. |
30
+
|`https.handler`| Handler for HTTPS requests. If you want to share a handler with all servers, use a top-level `handler` config property instead. |
31
+
|`https.*`| Any other properties supported by [https.createServer](https://nodejs.org/dist/latest-v8.x/docs/api/https.html#https_https_createserver_options_requestlistener) can be added to the https object, except `secureProtocol` and `secureOptions` which are set to recommended values. |
32
+
33
+
If successful, the `create-servers` callback is passed an object with the
34
+
following properties:
35
+
36
+
| Property | Description |
37
+
|----------|-------------|
38
+
|`http`| The HTTP server that was created, if any |
39
+
|`https`| The HTTPS server that was created, if any |
40
+
41
+
### Certificate normalization
42
+
43
+
`create-servers` provides some conveniences for `https.ca`, `https.key`, and
44
+
`https.cert` config properties. You may use PEM data directly (inside a `Buffer`
45
+
or string) or a file name. When using a file name, you may also set an
46
+
`https.root` config property to enable using relative paths to cert/key files.
47
+
`https.ca` and `https.cert` also support specifying an Array of certs/files.
48
+
49
+
## NOTE on Security
7
50
Inspired by [`iojs`][iojs] and a well written [article][article], we have defaulted
8
51
our [ciphers][ciphers] to support "perfect-forward-security" as well as removing insecure
9
52
cipher suites from being a possible choice. With this in mind,
10
53
be aware that we will no longer support ie6 on windows XP by default.
0 commit comments