mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
commands: Add TLS/HTTPS support to hugo server
* commands: Add TLS/HTTPS support to hugo server The "auto cert" handling in this PR is backed by mkcert (see link below). To get this up and running on a new PC, you can: ``` hugo server trust hugo server --tlsAuto ``` When `--tlsAuto` (or `--tlsCertFile` and `--tlsKeyFile`) is set and no `--baseURL` is provided as a flag, the server is started with TLS and `https` as the protocol. Note that you only need to run `hugo server trust` once per PC. If you already have the key and the cert file (e.g. by using mkcert directly), you can do: ``` hugo server --tlsCertFile mycert.pem --tlsKeyFile mykey.pem ``` See https://github.com/FiloSottile/mkcert Fixes #11064
This commit is contained in:
committed by
GitHub
parent
536bf71abe
commit
cf38c73f53
@@ -18,6 +18,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
@@ -389,6 +390,9 @@ func (r *rootCommand) PreRun(cd, runner *simplecobra.Commandeer) error {
|
||||
if r.quiet {
|
||||
r.Out = io.Discard
|
||||
}
|
||||
// Used by mkcert (server).
|
||||
log.SetOutput(r.Out)
|
||||
|
||||
r.Printf = func(format string, v ...interface{}) {
|
||||
if !r.quiet {
|
||||
fmt.Fprintf(r.Out, format, v...)
|
||||
|
Reference in New Issue
Block a user