feat: add managed ACME listener and log rotation
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
var acmeHTTPPort int
|
||||
var acmeHTTPHost string
|
||||
|
||||
var acmeHTTPCmd = &cobra.Command{
|
||||
Use: "acme-http",
|
||||
@@ -18,9 +19,13 @@ var acmeHTTPCmd = &cobra.Command{
|
||||
root := os.Getenv("ACME_WEBROOT")
|
||||
if root == "" { root = "/var/lib/trojan-acme-webroot" }
|
||||
if err := os.MkdirAll(filepath.Join(root, ".well-known", "acme-challenge"), 0750); err != nil { return err }
|
||||
addr := fmt.Sprintf("127.0.0.1:%d", acmeHTTPPort)
|
||||
addr := fmt.Sprintf("%s:%d", acmeHTTPHost, acmeHTTPPort)
|
||||
return http.ListenAndServe(addr, http.FileServer(http.Dir(root)))
|
||||
},
|
||||
}
|
||||
|
||||
func init() { acmeHTTPCmd.Flags().IntVar(&acmeHTTPPort, "port", 8082, "ACME HTTP listener port"); rootCmd.AddCommand(acmeHTTPCmd) }
|
||||
func init() {
|
||||
acmeHTTPCmd.Flags().StringVar(&acmeHTTPHost, "host", "127.0.0.1", "ACME HTTP listener host")
|
||||
acmeHTTPCmd.Flags().IntVar(&acmeHTTPPort, "port", 8082, "ACME HTTP listener port")
|
||||
rootCmd.AddCommand(acmeHTTPCmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user