Skip to content

Fix Let's Encrypt issue #9

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

Merged
merged 1 commit into from
Sep 7, 2018
Merged
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
11 changes: 7 additions & 4 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import:
version: 7abdd30a878efb3673ce4dfe0070570a6c9444c8
subpackages:
- lnrpc
- package: golang.org/x/crypto
- package: github.com/golang/crypto
version: 3d37316aaa6bd9929127ac9a527abf408178ea7b
subpackages:
- acme/autocert
- package: google.golang.org/grpc
Expand Down
11 changes: 2 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"reflect"
"time"

"golang.org/x/crypto/acme/autocert"
"github.com/golang/crypto/acme/autocert"

"github.com/gorilla/mux"
)
Expand Down Expand Up @@ -157,14 +157,7 @@ func main() {

// As we'd like all requests to default to https, redirect all regular
// http requests to the https version of the faucet.
go http.ListenAndServe(":80", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
targetURL := "https://" + r.Host + r.URL.String()
if len(r.URL.RawQuery) > 0 {
targetURL += "?" + r.URL.RawQuery
}

http.Redirect(w, r, targetURL, http.StatusPermanentRedirect)
}))
go http.ListenAndServe(":80", m.HTTPHandler(nil))

// Finally, create the http server, passing in our TLS configuration.
httpServer := &http.Server{
Expand Down