GolangNote

Golang笔记

Golang 实现的 Let’s Encrypt 验证响应handler

Permalink

简单的web 服务,响应Let’s Encrypt 域名所有者验证,不用 nginx 大器

Golang 实现的 Let’s Encrypt 验证响应handler

Go: 响应Let’s Encrypt 域名所有者验证
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main

import (
	"flag"
	"log"
	"net/http"
)

func main() {
	var dir = flag.String("dir", ".", "folder")
	var port = flag.String("p", "80", "port")

	flag.Parse()

	log.Println("dir : ", *dir)
	log.Println("port : ", *port)

	staticHandler := http.StripPrefix("/.well-known/acme-challenge/", http.FileServer(http.Dir(*dir)))
	http.Handle("/.well-known/acme-challenge/", staticHandler)
	srv := &http.Server{Addr: ":" + *port}

	log.Fatal(srv.ListenAndServe())
}

Related articles

Golang sync.WaitGroup 的 Wait 超时处理

sync.WaitGroup 使用 `Add(1)`、`Done()`、`Wait()`组合来实现多协程等待,如果某一协程未能合理处理错误,导致无法退出,此时需要引入超时机制。下面是一种超时处理方法。...

Write a Comment to "Golang 实现的 Let’s Encrypt 验证响应handler"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.16.5 Processed in 0ms