|
@@ -22,7 +22,7 @@ import (
|
|
|
)
|
|
|
|
|
|
/*
|
|
|
- Zoraxy Dynamic Proxy
|
|
|
+Zoraxy Dynamic Proxy
|
|
|
*/
|
|
|
type RouterOption struct {
|
|
|
Port int
|
|
@@ -122,12 +122,21 @@ func (router *Router) StartProxyService() error {
|
|
|
router.server = &http.Server{Addr: ":" + strconv.Itoa(router.Option.Port), Handler: router.mux}
|
|
|
router.Running = true
|
|
|
|
|
|
- if router.Option.Port == 443 && router.Option.ForceHttpsRedirect {
|
|
|
+ if router.Option.Port != 80 && router.Option.ForceHttpsRedirect {
|
|
|
//Add a 80 to 443 redirector
|
|
|
httpServer := &http.Server{
|
|
|
Addr: ":80",
|
|
|
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
- http.Redirect(w, r, "https://"+r.Host+r.RequestURI, http.StatusTemporaryRedirect)
|
|
|
+ protocol := "http://"
|
|
|
+ if router.Option.UseTls {
|
|
|
+ protocol = "https://"
|
|
|
+ }
|
|
|
+ if router.Option.Port == 443 && router.Option.UseTls {
|
|
|
+ http.Redirect(w, r, protocol+r.Host+r.RequestURI, http.StatusTemporaryRedirect)
|
|
|
+ } else {
|
|
|
+ http.Redirect(w, r, protocol+r.Host+":"+strconv.Itoa(router.Option.Port)+r.RequestURI, http.StatusTemporaryRedirect)
|
|
|
+ }
|
|
|
+
|
|
|
}),
|
|
|
ReadTimeout: 3 * time.Second,
|
|
|
WriteTimeout: 3 * time.Second,
|
|
@@ -311,7 +320,7 @@ func (router *Router) SetRootProxy(proxyLocation string, requireTLS bool) error
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//Helpers to export the syncmap for easier processing
|
|
|
+// Helpers to export the syncmap for easier processing
|
|
|
func (r *Router) GetSDProxyEndpointsAsMap() map[string]*SubdomainEndpoint {
|
|
|
m := make(map[string]*SubdomainEndpoint)
|
|
|
r.SubdomainEndpoint.Range(func(key, value interface{}) bool {
|