Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for https #53

Open
wants to merge 2 commits into
base: angularjs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ set 'NODE_ENV' to something else than 'production' or install the npm
dependencies with a '--debug' flag. All the development dependencies are moved
into devDependencies to avoid slow installs of the actual released software.

## Configuring

The following options are configurable in the package.json file (in config):

port: the port used to start the server
hostname: the interface listened by the server
bucket [optional] : the S3 bucket used to deploy the application
https : set to true to enable https on the server (default http)

### Debug and Release builds

> npm install --debug # to force development dependencies
Expand Down
26 changes: 20 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ var config = {
hostname: process.env.HOSTNAME || pkg.config.hostname,
debug: Boolean($.util.env.debug) || (process.env.NODE_ENV === 'development'),
production: Boolean($.util.env.production) || (process.env.NODE_ENV === 'production'),
bucket: pkg.config.bucket
bucket: pkg.config.bucket,
protocol: (pkg.config.https === true) ? 'https' : 'http'
};

// Test server URL (shared with server.js)
var url = ['http://', config.hostname + ':' + config.port, '/'].join('');
var url = [config.protocol + '://', config.hostname + ':' + config.port, '/'].join('');

// Global vars used across the test tasks
var testServerCmdAndArgs = pkg.scripts.start.split(/\s/);
Expand All @@ -55,7 +56,10 @@ var testServer = exec({
checkHTTPResponse: false
},
log: $.util.log,
stopSignal: 'SIGTERM'
stopSignal: 'SIGTERM',
httpOptions: {
rejectUnauthorized: false
}
});

// The last test run result
Expand Down Expand Up @@ -232,11 +236,21 @@ gulp.task('watch', ['build'], function() {
gulp.watch(['dist/**/*.js', 'dist/**/*.css'], integrationTasks);

$.util.log('Initialise BrowserSync on port 8081');
browserSync.init({

var options = {
files: 'dist/**/*',
proxy: [config.hostname, config.port].join(':'),
proxy: {
target: config.protocol + '://' + config.hostname + ':' + config.port
},
port: 8081
});
};
if (config.protocol === 'https') {
options.https = {
key: 'server/key.pem',
cert: 'server/cert.pem'
};
}
browserSync.init(options);
});
});

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "git",
"url": "https://github.com/SC5/gulp-bobrsass-boilerplate.git"
},
"version": "0.5.0",
"version": "0.5.1",
"engines": {
"node": ">=0.10.10",
"npm": ">=1.2.15"
Expand All @@ -19,7 +19,7 @@
"browser-sync": "^2.7.13",
"del": "^1.1.1",
"event-stream": "^3.2.1",
"exec-wait": "^0.0.3",
"exec-wait": "^0.0.5",
"git-hooks": "1.0.0-rc.1",
"gulp": "^3.8.10",
"gulp-awspublish": "^3.0.0",
Expand Down Expand Up @@ -53,7 +53,8 @@
"config": {
"port": 8080,
"hostname": "localhost",
"bucket": ""
"bucket": "",
"https": true
},
"scripts": {
"build": "gulp build",
Expand Down
24 changes: 24 additions & 0 deletions server/cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIIEGzCCAwOgAwIBAgIJAJrso4p7QpGnMA0GCSqGSIb3DQEBBQUAMGYxCzAJBgNV
BAYTAkZJMQowCAYDVQQIEwEtMREwDwYDVQQHEwhIZWxzaW5raTEWMBQGA1UEChMN
U0M1IE9ubGluZSBPeTEUMBIGA1UECxMLRGV2ZWxvcG1lbnQxCjAIBgNVBAMUASow
HhcNMTUxMjA0MTI0MDA0WhcNMjUxMjAxMTI0MDA0WjBmMQswCQYDVQQGEwJGSTEK
MAgGA1UECBMBLTERMA8GA1UEBxMISGVsc2lua2kxFjAUBgNVBAoTDVNDNSBPbmxp
bmUgT3kxFDASBgNVBAsTC0RldmVsb3BtZW50MQowCAY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-----END CERTIFICATE-----
19 changes: 16 additions & 3 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
var express = require('express'),
app = express(),
https = require('https'),
fs = require('fs'),
url = require('url'),
pkg = require('../package.json'),
config = {
version: pkg.version,
port: process.env.PORT || pkg.config.port,
hostname: process.env.HOSTNAME || pkg.config.hostname
hostname: process.env.HOSTNAME || pkg.config.hostname,
https: pkg.config.https || false
};

// Poor man's rewrite
Expand All @@ -24,6 +27,16 @@ app.use(function(req, res, next) {
next();
});
app.use(express.static(__dirname + '/../dist'));
app.listen(config.port);

console.log('Stub server running on port ' + config.port);
var proto = 'http';
if (config.https) {
https.createServer({
key: fs.readFileSync('server/key.pem'),
cert: fs.readFileSync('server/cert.pem')
}, app).listen(config.port);
proto='https';
} else {
app.listen(config.port);
}

console.log('Stub server (' + proto + ') running on port ' + config.port);
27 changes: 27 additions & 0 deletions server/key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA4cpP9zSyGZzK81Bw5V347thaKTBu1lbcvE7k8A2N5GYJkOLj
J1r1iLB9z91Y8zeH0o1FIilDkqaqIKtXdJOIhubSPPVVetnKPuIXYXQTrsubxcYj
7Iv02foFpg6BCW0/yUqiryVwMQTEn1mNnDWtLDlO4ANPqxcdf9T/+VmX1Gri1NLq
tsCLEZF+BtaQhuOmU+mzSV6cIV86F5p1NXsnmEe699LTBW4YpTWdjmO6jW0SjyQZ
28D/JP4fzIpt7bcp6qFmeI+bt7SzVpiQfYOBjN4jpO32Ohj3ugS0Xt+JPN4o8vtR
zXlpIaMtZUvMmUadifiiJrha2Y9+u/hMQdBsGwIDAQABAoIBAFUR2JcXL5Me1Ahg
YmjIwyWaNj4WlWwERh5cyzz2nmNTXn9MPLFzP9dER+KtTvo0DeRyfX2ldmQmjyrH
46d0fpf1F3kIJjCnJeATZyO8jD3rUMFvKdHR2WrXHJG4HT3j/4hjqm+6905Asa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