第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Go - ReverseProxy to Apache 代理錯(cuò)誤:x509:證書(shū)由未知機(jī)構(gòu)簽名

Go - ReverseProxy to Apache 代理錯(cuò)誤:x509:證書(shū)由未知機(jī)構(gòu)簽名

Go
尚方寶劍之說(shuō) 2021-11-29 16:12:28
我用 Go 編寫(xiě)的我自己的 ReverseProxy 有一些麻煩。我想將我的 Golang-Webserver 與我的 Apache Webserver 連接起來(lái)。我的 Apache 網(wǎng)絡(luò)服務(wù)器也應(yīng)該在 https 和反向代理上運(yùn)行。所以我寫(xiě)了以下代碼,但我總是收到錯(cuò)誤:代理錯(cuò)誤:x509:由未知機(jī)構(gòu)簽名的證書(shū)。那么apache必須使用與apache相同的證書(shū)還是有什么問(wèn)題?這里有一些代碼片段,但我認(rèn)為沒(méi)有 ssl 的證書(shū)有問(wèn)題,一切正常:(func (p *Proxy) directorApache(req *http.Request) {    mainServer := fmt.Sprintf("%s:%d", Config.HostMain, Config.PortMain)    req.URL.Scheme = "https"    req.URL.Host = mainServer}func (p *Proxy) directorGo(req *http.Request) {    goServer := fmt.Sprintf("%s:%d", Config.GoHost, Config.GoPort)    req.URL.Scheme = "http"    req.URL.Host = goServer}func (p *Proxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {    fmt.Println(req.URL.Path)    if p.isGoRequest(req) {        fmt.Println("GO")        p.goProxy.ServeHTTP(rw, req)        return    }    p.httpProxy.ServeHTTP(rw, req)}func main() {    var configPath = flag.String("conf", "./configReverse.json", "Path to the Json config file.")    flag.Parse()    proxy := New(*configPath)    cert, err := tls.LoadX509KeyPair(Config.PathCert, Config.PathPrivateKey)    if err != nil {        log.Fatalf("server: loadkeys: %s", err)    }    config := tls.Config{InsecureSkipVerify: true, Certificates: []tls.Certificate{cert}}    listener, err := net.Listen("tcp",    net.JoinHostPort(proxy.Host, strconv.Itoa(proxy.Port)))    if err != nil {        log.Fatalf("server: listen: %s", err)    }    log.Printf("server: listening on %s")    proxy.listener = tls.NewListener(listener, &config)    serverHTTPS := &http.Server{        Handler:   proxy.mux,        TLSConfig: &config,    }    if err := serverHTTPS.Serve(proxy.listener); err != nil {        log.Fatal("SERVER ERROR:", err)    }   }我嘗試了很多并生成了幾個(gè)自簽名 SSL 證書(shū),但沒(méi)有解決我的問(wèn)題。希望有人可以幫助我。
查看完整描述

1 回答

?
收到一只叮咚

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超5個(gè)贊

如果您在后端服務(wù)器中使用自簽名證書(shū),則需要告訴代理的 http 客戶端不要驗(yàn)證該證書(shū)。


您可以覆蓋 http 包的默認(rèn)值:


http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

或者專(zhuān)門(mén)為您的代理創(chuàng)建一個(gè)新的傳輸:


httpProxy.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},

}


查看完整回答
反對(duì) 回復(fù) 2021-11-29
  • 1 回答
  • 0 關(guān)注
  • 157 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)