I have a reverse proxy in golang which Listens on two different ports and
redirect to respective servers. the server is hosted in aws.
One is by default listening on 80  and another one is listening on port: 90

port :80 proxy   -> Redirects to   -> 9000
port :90 proxy     -> Redirects to --> 9095

I can see both listening ports using command, sudo ss -lptn 'sport = :80'
and sudo ss -lptn 'sport = :90' respectively.

I tried like
     subdomin.domine.com  -> as by default is redirect to port 80
       - I can view logs in my proxy program.
       - it is working fine.

but I tried like
     subdomin.domine.com:90 -> request doesn't reach my server.
        - I can view any logs in my program.
        - It doesn't serve any error messages too.

please find my code sample below.

go func() {
   mux80 := http.NewServeMux()
   mux80.HandleFunc("/", onRequest80)
   log.Print("Listening on: 80")

   server80 := http.Server{
      Addr:         ":80",
      ReadTimeout:  90 * time.Second,
      WriteTimeout: 90 * time.Second,
      Handler:      mux80,
   }

   err := server80.ListenAndServe()
   if err != nil {
      log.Printf("Error in running http proxy server: %s", err.Error())
   }
}()

log.Print("Listerning on: 90")
mux90 := http.NewServeMux()
mux90.HandleFunc("/", onRequest90)
server90 := http.Server{
   Addr:         ":90",
   ReadTimeout:  90 * time.Second,
   WriteTimeout: 90 * time.Second,
   Handler:      mux90,
}

err := server90.ListenAndServe()
if err != nil {
   log.Printf("Error in running http proxy server: %s", err.Error())
}


Please share your feedback.

cheers,
Hariprasad.


>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to