Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Add 'dev' command that bypasses privileged ports and SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyAghion committed Jan 16, 2019
1 parent db81aaa commit 3607d22
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ A tiny app that 301 redirects requests to www.artsy.net

### Deploy

This app is deployed on Amazon OpsWorks. [Click here to deploy](https://console.aws.amazon.com/opsworks/home?region=us-east-1#/stack/7db728d1-44a8-49e0-8362-92e4723c898e/deployments/deploy-app).
This app is deployed on Amazon OpsWorks. [Click here to deploy](https://console.aws.amazon.com/opsworks/home?region=us-east-1#/stack/7db728d1-44a8-49e0-8362-92e4723c898e/deployments/deploy-app).

### Development

npm run dev

### Testing

N/A
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
"start": "node server.js",
"dev": "NODE_ENV=development node server.js"
},
"repository": {
"type": "git",
Expand Down
15 changes: 10 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ var morgan = require('morgan');
var path = require('path');
var fs = require('fs');
var app = express();
var nodeEnv = process.env.NODE_ENV ? process.env.NODE_ENV : 'production'
var port = nodeEnv == 'production' ? 80 : 3000
var ssl = nodeEnv == 'production'
app.use(morgan('combined'));
app.use('/(.well-known/)?apple-app-site-association', artsyEigenWebAssociation);
app.use(function(req, res, next) {
res.setHeader('Strict-Transport-Security', 'max-age=0');
res.redirect(301, 'https://www.artsy.net' + req.url);
});
http.createServer(app).listen(80);
https.createServer({
key: fs.readFileSync('/srv/www/artsy_wwwify/shared/config/ssl.key').toString(),
cert: fs.readFileSync('/srv/www/artsy_wwwify/shared/config/ssl.crt').toString()
}, app).listen(443);
http.createServer(app).listen(port);
if (ssl) {
https.createServer({
key: fs.readFileSync('/srv/www/artsy_wwwify/shared/config/ssl.key').toString(),
cert: fs.readFileSync('/srv/www/artsy_wwwify/shared/config/ssl.crt').toString()
}, app).listen(443);
}

0 comments on commit 3607d22

Please sign in to comment.