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

Added redirection for SSL. #4

Open
wants to merge 6 commits into
base: production
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
24 changes: 24 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,37 @@ var ioOptions = {
rememberTransport: false,
transports: ['WebSocket', 'AJAX long-polling']
};

var https = require('https');
var fs = require('fs');

var options = {
key: fs.readFileSync('/etc/letsencrypt/live/infragram.org/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/infragram.org/cert.pem'),
ca: fs.readFileSync('/etc/letsencrypt/live/infragram.org/fullchain.pem')
};

var sserver = https.createServer(options, app);

var io = require('socket.io', ioOptions).listen(server, {log: false});
var sio = require('socket.io', ioOptions).listen(sserver, {log: false});
//var io = require('socket.io', ioOptions).listen(server);
//var sio = require('socket.io', ioOptions).listen(sserver);

// all environments
app.set('port', process.env.PORT || 80);
//app.set('port', process.env.PORT || 8001);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.use(function(req,res,next) {
if (!/https/.test(req.protocol)){
res.redirect("https://" + req.headers.host + req.url);
} else {
return next();
}
});

app.use(express.favicon(__dirname + '/public/images/favicon.ico'));
app.use(express.logger('dev'));
app.use(express.json());
Expand Down
8 changes: 5 additions & 3 deletions views/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ block content
p Infragram is an online tool for analyzing plant health with near-infrared imagery. To learn more, <a href="http://publiclab.org/wiki/near-infrared-camera">read about our open source cameras</a>, or <a href="http://store.publiclab.org/products/infragram-diy-filter-pack">buy a modded camera</a> from the Public Lab non-profit.</p>
p You can upload images from a camera you have modified with <a href="http://store.publiclab.org/products/infragram-diy-filter-pack">our DIY Filter Pack</a>, or with our <a href="http://store.publiclab.org/products/infragram-webcam">pre-modified Point and Shoot Infragram Camera</a>.
br

p
a.btn-primary.btn-large(style="float:left;" href="/sandbox/") Begin now &raquo;
a.btn.btn-default.btn-large(style="float:left;" href="https://publiclab.org/wiki/multispectral-imaging") Get help &amp; learn more

a.btn.btn-default.btn-large(style="float:left;;margin-left:5px;" href="https://publiclab.org/wiki/multispectral-imaging") Learn more
a.btn.btn-default.btn-large(style="float:left;margin-left:5px;" href="https://publiclab.org/questions/new?tags=infragram,infrared,multispectral-imaging,ndvi,question:infragram,question:infrared,question:multispectral-imaging,question:ndvi&template=question") Ask a question

div.span4(style="margin-bottom:6px;")
img(width="100%" src="/images/infragram-animated.gif")
Expand Down Expand Up @@ -46,7 +47,8 @@ block content
div.meta
span.author= "by "+(image.author || "anon")
span.updated_at= " on "+image.updated_at+" "
a(href="#delete-modal" data-toggle="modal" onclick="$('#delete-form').attr('action', '/delete/" + image._id + "');") Delete
a(href="mailto:[email protected]?subject=Reporting spam on Infragram.org&body=https://infragram.org") Flag
a(href="#delete-modal" data-toggle="modal" onclick="$('#delete-form').attr('action', '/delete/" + image._id + "');") X
if (index+1) % 4 == 0
| </div><hr style="clear:both;"/><div class="row-fluid">

Expand Down