【发布时间】:2018-01-15 11:18:39
【问题描述】:
我的站点 https://a-b-c.com 和 https://www.x-y-z.com 分别在端口 4444 和 5555 上的反向代理后面运行。
我已将它们配置为使用letsencrypt tls证书,但现在使用反向代理时出现错误,我认为我需要使用包含其证书的&tls.config{},但我不知道如何设置它.
我的 ReverseProxy 看起来像:
director := func(req *http.Request) {
log.Println(req.Host)
switch req.Host {
case "a-b-c-.com":
req.URL.Host = "localhost:4444"
req.URL.Scheme = "https"
case "x-y-z.com":
req.URL.Host = "localhost:5555"
req.URL.Scheme = "https"
}
proxy := &httputil.ReverseProxy{Director: director}
proxy.Transport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
log.Fatalln(http.ListenAndServe(":443", proxy))
【问题讨论】:
标签: ssl go reverse-proxy