@@ -7,8 +7,12 @@ var colors = require('colors/safe'),
7
7
httpServer = require ( '../lib/http-server' ) ,
8
8
portfinder = require ( 'portfinder' ) ,
9
9
opener = require ( 'opener' ) ,
10
- fs = require ( 'fs' ) ,
11
- argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) ) ;
10
+ fs = require ( 'fs' ) ;
11
+ var argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) , {
12
+ alias : {
13
+ tls : 'ssl'
14
+ }
15
+ } ) ;
12
16
var ifaces = os . networkInterfaces ( ) ;
13
17
14
18
process . title = 'http-server' ;
@@ -38,17 +42,17 @@ if (argv.h || argv.help) {
38
42
' -U --utc Use UTC time format in log messages.' ,
39
43
' --log-ip Enable logging of the client\'s IP address' ,
40
44
'' ,
41
- ' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com' ,
45
+ ' -P --proxy Fallback proxy if the request cannot be resolved. e.g.: http://someurl.com' ,
42
46
' --proxy-options Pass options to proxy using nested dotted objects. e.g.: --proxy-options.secure false' ,
43
47
'' ,
44
48
' --username Username for basic authentication [none]' ,
45
49
' Can also be specified with the env variable NODE_HTTP_SERVER_USERNAME' ,
46
50
' --password Password for basic authentication [none]' ,
47
51
' Can also be specified with the env variable NODE_HTTP_SERVER_PASSWORD' ,
48
52
'' ,
49
- ' -S --ssl Enable https. ' ,
50
- ' -C --cert Path to ssl cert file (default: cert.pem). ' ,
51
- ' -K --key Path to ssl key file (default: key.pem). ' ,
53
+ ' -S --tls -- ssl Enable secure request serving with TLS/SSL (HTTPS) ' ,
54
+ ' -C --cert Path to TLS cert file (default: cert.pem)' ,
55
+ ' -K --key Path to TLS key file (default: key.pem)' ,
52
56
'' ,
53
57
' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]' ,
54
58
' --no-dotfiles Do not show dotfiles' ,
@@ -61,7 +65,7 @@ if (argv.h || argv.help) {
61
65
62
66
var port = argv . p || argv . port || parseInt ( process . env . PORT , 10 ) ,
63
67
host = argv . a || '0.0.0.0' ,
64
- ssl = argv . S || argv . ssl ,
68
+ tls = argv . S || argv . tls ,
65
69
proxy = argv . P || argv . proxy ,
66
70
proxyOptions = argv [ 'proxy-options' ] ,
67
71
utc = argv . U || argv . utc ,
@@ -156,7 +160,7 @@ function listen(port) {
156
160
}
157
161
}
158
162
159
- if ( ssl ) {
163
+ if ( tls ) {
160
164
options . https = {
161
165
cert : argv . C || argv . cert || 'cert.pem' ,
162
166
key : argv . K || argv . key || 'key.pem'
@@ -179,16 +183,18 @@ function listen(port) {
179
183
180
184
var server = httpServer . createServer ( options ) ;
181
185
server . listen ( port , host , function ( ) {
182
- var protocol = ssl ? 'https://' : 'http://' ;
186
+ var protocol = tls ? 'https://' : 'http://' ;
183
187
184
- logger . info ( [ colors . yellow ( 'Starting up http-server, serving ' ) ,
188
+ logger . info ( [
189
+ colors . yellow ( 'Starting up http-server, serving ' ) ,
185
190
colors . cyan ( server . root ) ,
186
- ssl ? ( colors . yellow ( ' through' ) + colors . cyan ( ' https' ) ) : ''
191
+ tls ? ( colors . yellow ( ' through' ) + colors . cyan ( ' https' ) ) : ''
187
192
] . join ( '' ) ) ;
188
193
189
194
logger . info ( [ colors . yellow ( '\nhttp-server version: ' ) , colors . cyan ( require ( '../package.json' ) . version ) ] . join ( '' ) ) ;
190
195
191
- logger . info ( [ colors . yellow ( '\nhttp-server settings: ' ) ,
196
+ logger . info ( [
197
+ colors . yellow ( '\nhttp-server settings: ' ) ,
192
198
( [ colors . yellow ( 'CORS: ' ) , argv . cors ? colors . cyan ( argv . cors ) : colors . red ( 'disabled' ) ] . join ( '' ) ) ,
193
199
( [ colors . yellow ( 'Cache: ' ) , argv . c ? ( argv . c === '-1' ? colors . red ( 'disabled' ) : colors . cyan ( argv . c + ' seconds' ) ) : colors . cyan ( '3600 seconds' ) ] . join ( '' ) ) ,
194
200
( [ colors . yellow ( 'Connection Timeout: ' ) , argv . t === '0' ? colors . red ( 'disabled' ) : ( argv . t ? colors . cyan ( argv . t + ' seconds' ) : colors . cyan ( '120 seconds' ) ) ] . join ( '' ) ) ,
0 commit comments