Switch for manual forwarding to reverse proxy; this should be websocket compatible
This commit is contained in:
parent
324308f5d6
commit
2edd304c34
19
main.go
19
main.go
|
@ -11,6 +11,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
@ -327,7 +329,13 @@ func startServer(srv *http.Server) {
|
||||||
|
|
||||||
serveMux := http.NewServeMux()
|
serveMux := http.NewServeMux()
|
||||||
if !*devmode {
|
if !*devmode {
|
||||||
serveMux.HandleFunc("dev."+DOMAIN_NAME+"/", forwardRequest(8081, "http"))
|
//serveMux.HandleFunc("dev."+DOMAIN_NAME+"/", forwardRequest(8081, "http"))
|
||||||
|
url, err := url.Parse("http://localhost:8081")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("unable to parse reverse proxy path: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
serveMux.Handle("dev."+DOMAIN_NAME+"/", httputil.NewSingleHostReverseProxy(url))
|
||||||
}
|
}
|
||||||
serveMux.HandleFunc("/", rootHandler)
|
serveMux.HandleFunc("/", rootHandler)
|
||||||
//serveMux.Handle("/certbot/", http.StripPrefix("/certbot/", http.FileServer(http.Dir("./certbot-tmp"))))
|
//serveMux.Handle("/certbot/", http.StripPrefix("/certbot/", http.FileServer(http.Dir("./certbot-tmp"))))
|
||||||
|
@ -407,7 +415,14 @@ func startRedirectServer(srv *http.Server) {
|
||||||
serveMux := http.NewServeMux()
|
serveMux := http.NewServeMux()
|
||||||
// copied from https://gist.github.com/d-schmidt/587ceec34ce1334a5e60
|
// copied from https://gist.github.com/d-schmidt/587ceec34ce1334a5e60
|
||||||
if !*devmode {
|
if !*devmode {
|
||||||
serveMux.HandleFunc("dev."+DOMAIN_NAME+"/", forwardRequest(8081, "http"))
|
//serveMux.HandleFunc("dev."+DOMAIN_NAME+"/", forwardRequest(8081, "http"))
|
||||||
|
url, err := url.Parse("http://localhost:8081")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("unable to parse reverse proxy path: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
serveMux.Handle("dev."+DOMAIN_NAME+"/", httputil.NewSingleHostReverseProxy(url))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
serveMux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
serveMux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
Loading…
Reference in New Issue