FAQ
I want to server two domains from same machine.
In the domain registrar I pointed the two domains to same IP address.

On the Golang server I have this running for https://www.MyDomain01.net.

How to modify it to listen also to https://www.MyDomain02.net?
I have certpem01 and keypem01 for MyDomain01 and
certpem02 and keypem02 for MyDomain02.

The question is how to serve both domains from same machine.

===================================

       var addr01 string = "www.MyDomain01.net"

        cert01, err01 := tls.LoadX509KeyPair(certpem01, keypem01) if err01
!= nil { fmt.Printf("LoadX509KeyPair: %s", err01) }

config01 := &tls.Config{
Rand: rand.Reader,
Certificates: []tls.Certificate{cert01},
CipherSuites: []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
},
}

         srv01 := &http.Server{}
ln4_01, err01 := net.Listen("tcp4", addr01 +":443")
if err01 != nil {
fmt.Printf("\n Error:net.Listen(tcp4): %s", err01)
}
tlsListener4_01 :=
tls.NewListener(tcpKeepAliveListener{ln4_01.(*net.TCPListener)}, configTc)
go func() {
srvTc.Serve(tlsListener4_01)
}()
===================================

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Matt Silverlock at Apr 9, 2016 at 1:32 am
    Configure the GetCertificate field of tls.Config with a function that uses the provided ClientHelloInfo's ServerName field to determine the cert <=> hostname pairing: https://golang.org/pkg/crypto/tls/#Config

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Constantine Vassilev at Apr 9, 2016 at 1:57 am
    I am using Let's Encrypt.

    /Users/UserName/.local/share/letsencrypt/bin/letsencrypt --duplicate
    certonly -a manual --rsa-key-size 4096 -d MyDomain01.net -d
    www.MyDomain01.net -d MyDomain02.net -d www.MyDomain02.net

    That way I have multi domain certificate.

    I think this will solve the certificate issue.


    Now there is an issue with http to https redirection.

    I am using this:


    go func() {

    http.ListenAndServe(":80", http.HandlerFunc(redir))

    }()
    func redir(w http.ResponseWriter, r *http.Request) {

    if r.Host == "MyDomain01.net" || r.Host == "www.MyDomain01.net" {
    http.Redirect(w, r, "https://"+"www.MyDomain01.net"+r.RequestURI,
    http.StatusMovedPermanently)
    } else if r.Host == "MyDomain02.net" || r.Host == "www.MyDomain02.net" {
    http.Redirect(w, r, "https://"+"www.MyDomain02.net"+r.RequestURI,
    http.StatusMovedPermanently)
    }

    }
    It redirects but In the browser address bar I don't always see the lock
    icon.


    On Friday, April 8, 2016 at 6:32:54 PM UTC-7, Matt Silverlock wrote:

    Configure the GetCertificate field of tls.Config with a function that uses
    the provided ClientHelloInfo's ServerName field to determine the cert <=>
    hostname pairing: https://golang.org/pkg/crypto/tls/#Config
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 8, '16 at 4:47p
activeApr 9, '16 at 1:57a
posts3
users2
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase