Document the HTTP_ALL_INTERFACES feature

pull/41/head
Key Networks 7 years ago
parent 30b71ac492
commit 27616b95d4

@ -127,18 +127,32 @@ You should see the front page of the app (or the raw HTML with curl).
##### 8. Remote access via HTTPS ##### 8. Remote access via HTTPS
This app listens for HTTP requests on the looback interface (default port 3000). It can be reverse proxied by Nginx (which can proxy the HTTP as HTTPS), or accessed over an SSH tunnel as described below. This app listens for HTTP requests on the looback interface (default port 3000). It can be reverse proxied by Nginx (which can proxy the HTTP as HTTPS), or accessed over an SSH tunnel as described below.
The app can be made to listen on all interfaces for HTTP requests by setting HTTP_ALL_INTERFACES in the .env file, e.g.:
```
HTTP_ALL_INTERFACES=yes
```
Note that HTTP traffic is unencrypted, so this should only be done on a secure network, otherwise usernames and passwords will be exposed in plain text over the network.
The app can be made to listen on all interfaces for HTTPS requests by specifying HTTPS_PORT in the .env file, e.g.: The app can be made to listen on all interfaces for HTTPS requests by specifying HTTPS_PORT in the .env file, e.g.:
``` ```
HTTPS_PORT=3443 HTTPS_PORT=3443
``` ```
If HTTPS_PORT is not specified, then the app will only listen for HTTP requests on localhost.
The app can be made to listen on a specific interface for HTTPS requests by specifying HTTPS_HOST (the host name or IP address of the interface) in the .env file, e.g.: The app can be made to listen on a specific interface for HTTPS requests by specifying HTTPS_HOST (the host name or IP address of the interface) in the .env file, e.g.:
``` ```
HTTPS_HOST=12.34.56.78 HTTPS_HOST=12.34.56.78
``` ```
If HTTPS_HOST is not specified, but HTTPS_PORT is specified, then the app will listen for HTTPS requests on all interfaces. If HTTPS_HOST is not specified, but HTTPS_PORT is specified, then the app will listen for HTTPS requests on all interfaces.
###### Summary of listening states
| Environment variable | Protocol | Listen On | Port |
| :------------------: | :------: | :-------: | :--: |
| [none] | HTTP | localhost | 3000 |
| HTTP_PORT | HTTP | localhost | HTTP_PORT |
| HTTP_ALL_INTERFACES | HTTP | all interfaces | HTTP_PORT || 3000 |
| HTTPS_PORT | HTTPS | all interfaces | HTTPS_PORT |
| HTTPS_HOST | HTTPS | HTTPS_HOST | HTTPS_PORT |
###### TLS Certificate ###### TLS Certificate
For HTTPS you obviously need a TLS (SSL) certificate and private key pair. There are a few options: For HTTPS you obviously need a TLS (SSL) certificate and private key pair. There are a few options:

@ -30,17 +30,23 @@ app.set('https_port', https_port);
const https_host = process.env.HTTPS_HOST || null; const https_host = process.env.HTTPS_HOST || null;
app.set('https_host', https_host); app.set('https_host', https_host);
/** /** Create HTTPS server and listen for protocols on interfaces and ports
* Create HTTPS server and listen on localhost only for HTTP, unless the * according to environment variables as follows:
* environment variable HTTP_ALL_INTERFACES is set, and * Environment variable Protocol Listen On Port
* on all network interfaces for HTTPS if HTTPS_PORT is set in env, * -------------------- -------- --------- ----
* or on specific interface if HTTPS_HOST is set in env. * <none> HTTP localhost 3000
* HTTP_PORT HTTP localhost HTTP_PORT
* HTTP_ALL_INTERFACES HTTP all interfaces HTTP_PORT || 3000
* HTTPS_PORT HTTPS all interfaces HTTPS_PORT
* HTTPS_HOST HTTPS HTTPS_HOST HTTPS_PORT
*/ */
const http_all_int = process.env.HTTP_ALL_INTERFACES || null; const http_all_interfaces = process.env.HTTP_ALL_INTERFACES || null;
if (http_all_int) { if (http_all_interfaces) {
console.log('Listening for HTTP requests on port ' + http_port + ' on all interfaces');
app.listen(http_port); app.listen(http_port);
} else { } else {
console.log('Listening for HTTP requests on port ' + http_port + ' on localhost');
app.listen(http_port, 'localhost'); app.listen(http_port, 'localhost');
} }

@ -1,6 +1,6 @@
{ {
"name": "ztncui", "name": "ztncui",
"version": "0.4.1", "version": "0.4.2",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "node ./bin/www", "start": "node ./bin/www",

Loading…
Cancel
Save