-
Notifications
You must be signed in to change notification settings - Fork 73
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 per bundle certificates for static files and redirects. #163
Open
tolysz
wants to merge
7
commits into
snoyberg:master
Choose a base branch
from
tolysz:multiple-certs-sf+redir
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+204
−135
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ecbae7d
Add per bundle certificates for static files and redirects.
tolysz 1de6179
update sample configuration
tolysz 6133e7e
add reverse proxy
tolysz e4f5dba
Use better gzip default setting i.e. serve pre compressed version `.g…
tolysz 73488a1
Update readme for systemd being used in ubuntu
mac10688 a8ad8a2
Changed configuration of keter service from Upstart to systemd.
frt 7e54bcc
* Builds with `process` 1.6
tolysz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,8 @@ import Network.Wai.Application.Static (defaultFileServerSettings, | |
ssListing, staticApp) | ||
import qualified Network.Wai.Handler.Warp as Warp | ||
import qualified Network.Wai.Handler.WarpTLS as WarpTLS | ||
import Network.Wai.Middleware.Gzip (gzip) | ||
import qualified Network.TLS.SessionManager as TLSSession | ||
import Network.Wai.Middleware.Gzip (gzip, GzipSettings(..), GzipFiles(..)) | ||
import Prelude hiding (FilePath, (++)) | ||
import WaiAppStatic.Listing (defaultListing) | ||
import qualified Network.TLS as TLS | ||
|
@@ -51,21 +52,21 @@ type HostLookup = ByteString -> IO (Maybe (ProxyAction, TLS.Credentials)) | |
reverseProxy :: Bool | ||
-> Int -> Manager -> HostLookup -> ListeningPort -> IO () | ||
reverseProxy useHeader timeBound manager hostLookup listener = | ||
run $ gzip def $ withClient isSecure useHeader timeBound manager hostLookup | ||
run $ gzip def{gzipFiles = GzipPreCompressed GzipIgnore} $ withClient isSecure useHeader timeBound manager hostLookup | ||
where | ||
warp host port = Warp.setHost host $ Warp.setPort port Warp.defaultSettings | ||
(run, isSecure) = | ||
case listener of | ||
LPInsecure host port -> (Warp.runSettings (warp host port), False) | ||
LPSecure host port cert chainCerts key -> (WarpTLS.runTLS | ||
(connectClientCertificates hostLookup $ WarpTLS.tlsSettingsChain | ||
LPSecure host port cert chainCerts key session -> (WarpTLS.runTLS | ||
(connectClientCertificates hostLookup session $ WarpTLS.tlsSettingsChain | ||
cert | ||
(V.toList chainCerts) | ||
key) | ||
(warp host port), True) | ||
|
||
connectClientCertificates :: HostLookup -> WarpTLS.TLSSettings -> WarpTLS.TLSSettings | ||
connectClientCertificates hl s = | ||
connectClientCertificates :: HostLookup -> Bool -> WarpTLS.TLSSettings -> WarpTLS.TLSSettings | ||
connectClientCertificates hl session s = | ||
let | ||
[email protected]{..} = WarpTLS.tlsServerHooks s | ||
-- todo: add nested lookup | ||
|
@@ -74,7 +75,8 @@ connectClientCertificates hl s = | |
newOnServerNameIndication Nothing = | ||
return mempty -- we could return default certificate here | ||
in | ||
s { WarpTLS.tlsServerHooks = newHooks{TLS.onServerNameIndication = newOnServerNameIndication}} | ||
s { WarpTLS.tlsServerHooks = newHooks{TLS.onServerNameIndication = newOnServerNameIndication} | ||
, WarpTLS.tlsSessionManagerConfig = if session then (Just TLSSession.defaultConfig) else Nothing } | ||
|
||
withClient :: Bool -- ^ is secure? | ||
-> Bool -- ^ use incoming request header for IP address | ||
|
@@ -146,6 +148,7 @@ withClient isSecure useHeader bound manager hostLookup = | |
, redirconfigStatus = 301 | ||
, redirconfigActions = V.singleton $ RedirectAction SPAny | ||
$ RDPrefix True host' Nothing | ||
, redirconfigSsl = SSLTrue | ||
} | ||
|
||
performAction req (PAPort port tbound) = | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's missing to support this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pointer for others, I am happy with an absolute path.
I.e. I am using
letsencrypt
via https://github.com/lukas2511/dehydrated to generate certs in a fixed location in the filesystem (and I have to regenerate them every couple of months), then have my bundles to point to that absolute folders.