Skip to content
Browse files

Add option to enable an SSL Frontend for streamie (using SSL reverse …

…proxy, no direct serving)
  • Loading branch information...
1 parent ec39f7f commit 56603c1d61c09d2269d8d213e456a8481782df6b @cramforce committed
Showing with 15 additions and 11 deletions.
  1. +2 −1 config.sample.json
  2. +9 −6 lib/server.js
  3. +4 −4 public/index.html
View
3 config.sample.json
@@ -5,5 +5,6 @@
"port": 8888,
"imgurKey": "sdfgsdfgsdfgsdfgsdfg",
"staticFilesExpireSeconds": 0,
- "siteStreamOAuthToken": "asdasdfasd"
+ "siteStreamOAuthToken": "asdasdfasd",
+ "useSSL": false
}
View
15 lib/server.js
@@ -17,6 +17,7 @@ var host = config.hostNameAndOptionalPort;
var key = config.oauthKey;
var secret = config.oauthSecret;
var port = config.port;
+var useSSL = config.useSSL;
var IMGUR_KEY = config.imgurKey;
var cacheTime = config.staticFilesExpireSeconds || 0;
if(!host || !key || !secret) {
@@ -24,6 +25,8 @@ if(!host || !key || !secret) {
process.exit();
}
+var scheme = useSSL ? 'https' : 'http';
+
process.on('uncaughtException', function (err) {
console.log('[UNCAUGHT EXCEPTION] ' +err+'\n' + JSON.stringify(err, null, " "));
process.exit();
@@ -81,7 +84,7 @@ var server = http.createServer(function (request, response) {
if(otherhost.match(re)) {
targetHost = otherhost;
}
- var oauth_callback_url = "http://"+host+"/oauth_callback?host="+targetHost+"&js="+encodeURIComponent(url.query ? url.query.js : '')+"&hl="+encodeURIComponent(url.query ? url.query.hl : '');
+ var oauth_callback_url = scheme + "://"+host+"/oauth_callback?host="+targetHost+"&js="+encodeURIComponent(url.query ? url.query.js : '')+"&hl="+encodeURIComponent(url.query ? url.query.hl : '');
oauth.request(key, secret, oauth_callback_url, function (error, token, url, cont) {
if(error) {
@@ -94,7 +97,7 @@ var server = http.createServer(function (request, response) {
host: targetHost
};
- var transferURL = "http://"+host+"/transfer?token="+encodeURIComponent(temp);
+ var transferURL = scheme + "://"+host+"/transfer?token="+encodeURIComponent(temp);
console.log("Transfer via "+transferURL)
console.log("oauth step 1 success");
@@ -166,7 +169,7 @@ var server = http.createServer(function (request, response) {
console.log(error);
} else {
console.log("oauth step 3 success");
- var target = "http://"+url.query.host+"/oauth_transfer?oauth_token="+url.query.oauth_token+"&js="+encodeURIComponent(url.query.js)+"&hl="+encodeURIComponent(url.query ? url.query.hl : '');
+ var target = scheme + "://"+url.query.host+"/oauth_transfer?oauth_token="+url.query.oauth_token+"&js="+encodeURIComponent(url.query.js)+"&hl="+encodeURIComponent(url.query ? url.query.hl : '');
response.writeHead(302, {
'Location': target
});
@@ -284,12 +287,12 @@ var server = http.createServer(function (request, response) {
sub = sub[1];
if(sub == "www") { // redirect www to host without www
response.writeHead(302, { // onto Twitter
- 'Location': "http://"+host
+ 'Location': scheme + "://"+host
});
response.end()
} else if(sub == "js" || sub == "jsconf") { // redirect www to host without www
response.writeHead(302, { // onto Twitter
- 'Location': "http://" + host + "/js"
+ 'Location': scheme + "://" + host + "/js"
});
response.end()
}
@@ -298,7 +301,7 @@ var server = http.createServer(function (request, response) {
var domain = sub+".github.com"
request.url = "/streamie/public" + request.url;
request.headers.host = domain;
- console.log("Proxy to http://"+domain+request.url);
+ console.log("Proxy to "+scheme+"://"+domain+request.url);
var proxy = new httpProxy.HttpProxy(request, response);
proxy.proxyRequest(80, domain, request, response);
}
View
8 public/index.html
@@ -61,7 +61,7 @@
less.refresh(true); // localstorage caching is bad for frequent releases
</script>
-->
- <script type="text/javascript" src="http://www.google.com/jsapi">
+ <script type="text/javascript" src="//www.google.com/jsapi">
</script>
<script type="text/javascript">
google.load("language", "1");
@@ -117,7 +117,7 @@ <h1 id="logo"><a href="#" target="_self" class="i18n">streamie beta for <span id
We hate bloat as much as you do!
</p>
- <p><a href="/access" class="inject-hl" target="_self"><img src="http://a0.twimg.com/images/dev/buttons/sign-in-with-twitter-d.png" alt="Sign in with Twitter" /></a></p>
+ <p><a href="/access" class="inject-hl" target="_self"><img src="https://s3.amazonaws.com/twitter_production/images/dev/buttons/sign-in-with-twitter-d.png" alt="Sign in with Twitter" /></a></p>
<p class="point">
<ul>
<li><a href="/?hl=ar">في عربية</a></li>
@@ -132,7 +132,7 @@ <h1 id="logo"><a href="#" target="_self" class="i18n">streamie beta for <span id
</p>
<p class="subline i18n">Yes, this is beta software.<br>
<a href="#moreinfo" target="_self" id="showMoreInfo">More Info</a><br>
- <a href="http://twitter.com/streamie">Follow us on Twitter</a></p>
+ <a href="https://twitter.com/streamie">Follow us on Twitter</a></p>
<div id="moreinfo">
<h2 class="i18n">Cutting Edge Web Technology</h2>
<p class="i18n">
@@ -169,7 +169,7 @@ <h2 class="h i18n">Image Upload</h2>
<input type="button" value="Cancel" class="button close i18n" />
</div>
</div>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="/ext/underscore.js"></script>
<script src="ext/socket.io/socket.io.js"></script>
<!-- We use require.js for loading dependencies http://requirejs.org/ -->

0 comments on commit 56603c1

Please sign in to comment.
Something went wrong with that request. Please try again.