forked from socketstream/socketstream
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Owen Barnes
committed
Jun 23, 2011
1 parent
87d9ea8
commit 7e7e841
Showing
22 changed files
with
407 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Middleware: HTTP Redirect | ||
# -------------------------- | ||
# Redirects HTTP requests to HTTPS | ||
|
||
server = require('../utils/server.coffee') | ||
|
||
exports.call = (request, response, next) -> | ||
old_url = 'http://' + request.headers.host + request.url | ||
new_url = 'https://' + SS.config.https.domain + request.url | ||
server.redirect request, response, new_url | ||
SS.log.serve.httpsRedirect old_url, new_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Middleware: HTTPS Redirect | ||
# -------------------------- | ||
# Redirects incorrect HTTPS sent to the wrong host to the correct host for the SSL certificate | ||
|
||
server = require('../utils/server.coffee') | ||
|
||
# Will automatically redirect requests to an incorrect domain to the correct one | ||
exports.call = (request, response, next) -> | ||
|
||
if SS.config.https.enabled and hostsDiffer(request) | ||
# Redirect URL to correct host | ||
old_url = 'https://' + request.headers.host + request.url | ||
new_url = 'https://' + SS.config.https.domain + request.url | ||
server.redirect request, response, new_url | ||
SS.log.serve.httpsRedirect old_url, new_url | ||
else | ||
next() | ||
|
||
|
||
# PRIVATE | ||
|
||
hostsDiffer = (request) -> | ||
SS.config.https.domain and SS.config.https.ensure_domain and request.headers.host != SS.config.https.domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.