Skip to content

Commit

Permalink
gui: remove letsencrypt http redirect.
Browse files Browse the repository at this point in the history
This removes the letsencrypt http redirect because clients should be expecting an https service
and if there is a need to for a redirect the pool
operator's web server should be capable.
  • Loading branch information
dnldd committed Jan 5, 2021
1 parent a262db9 commit bb597f2
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"errors"
"fmt"
"html/template"
"net"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -266,33 +265,12 @@ func (ui *GUI) Run(ctx context.Context) {
}

if ui.cfg.UseLEHTTPS {
certCache := autocert.DirCache("certs")
certMgr := &autocert.Manager{
Prompt: autocert.AcceptTOS,
Cache: certCache,
Cache: autocert.DirCache("certs"),
HostPolicy: autocert.HostWhitelist(ui.cfg.Domain),
}

// Ensure port 80 is not already in use.
port80 := ":80"
listener, err := net.Listen("tcp", port80)
if err != nil {
log.Error("port 80 is already in use")
return
}

listener.Close()

// Redirect all regular http requests to their https endpoints.
go func() {
log.Info("Starting GUI server on port 80 (http, will forward to https)")
if err := http.ListenAndServe(port80,
certMgr.HTTPHandler(nil)); err != nil &&
!errors.Is(err, http.ErrServerClosed) {
log.Error(err)
}
}()

log.Info("Starting GUI server on port 443 (https)")
ui.server = &http.Server{
WriteTimeout: time.Second * 30,
Expand Down

0 comments on commit bb597f2

Please sign in to comment.