mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-01 13:17:21 +02:00
Fixed #435
This commit is contained in:
parent
49555c1191
commit
992dd231f2
@ -142,7 +142,7 @@ func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
/*
|
||||
handleRootRouting
|
||||
|
||||
This function handle root routing situations where there are no subdomain
|
||||
This function handle root routing (aka default sites) situations where there are no subdomain
|
||||
, vdir or special routing rule matches the requested URI.
|
||||
|
||||
Once entered this routing segment, the root routing options will take over
|
||||
@ -222,12 +222,10 @@ func (h *ProxyHandler) handleRootRouting(w http.ResponseWriter, r *http.Request)
|
||||
h.Parent.logRequest(r, false, 444, "root-noresponse", domainOnly)
|
||||
hijacker, ok := w.(http.Hijacker)
|
||||
if !ok {
|
||||
http.Error(w, "Hijacking not supported", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
conn, _, err := hijacker.Hijack()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
conn.Close()
|
||||
|
@ -264,5 +264,6 @@ func (ep *ProxyEndpoint) Remove() error {
|
||||
// use prepare -> remove -> add if you change anything in the endpoint
|
||||
// that effects the proxy routing src / dest
|
||||
func (ep *ProxyEndpoint) UpdateToRuntime() {
|
||||
ep.parent.ProxyEndpoints.Store(ep.RootOrMatchingDomain, ep)
|
||||
lookupHostname := strings.ToLower(ep.RootOrMatchingDomain)
|
||||
ep.parent.ProxyEndpoints.Store(lookupHostname, ep)
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ func (router *Router) getTargetProxyEndpointFromRequestURI(requestURI string) *P
|
||||
// Get the proxy endpoint from hostname, which might includes checking of wildcard certificates
|
||||
func (router *Router) getProxyEndpointFromHostname(hostname string) *ProxyEndpoint {
|
||||
var targetSubdomainEndpoint *ProxyEndpoint = nil
|
||||
hostname = strings.ToLower(hostname)
|
||||
ep, ok := router.ProxyEndpoints.Load(hostname)
|
||||
if ok {
|
||||
//Exact hit
|
||||
|
@ -70,9 +70,10 @@ func (router *Router) PrepareProxyRoute(endpoint *ProxyEndpoint) (*ProxyEndpoint
|
||||
|
||||
// Add Proxy Route to current runtime. Call to PrepareProxyRoute before adding to runtime
|
||||
func (router *Router) AddProxyRouteToRuntime(endpoint *ProxyEndpoint) error {
|
||||
lookupHostname := strings.ToLower(endpoint.RootOrMatchingDomain)
|
||||
if len(endpoint.ActiveOrigins) == 0 {
|
||||
//There are no active origins. No need to check for ready
|
||||
router.ProxyEndpoints.Store(endpoint.RootOrMatchingDomain, endpoint)
|
||||
router.ProxyEndpoints.Store(lookupHostname, endpoint)
|
||||
return nil
|
||||
}
|
||||
if !router.loadBalancer.UpstreamsReady(endpoint.ActiveOrigins) {
|
||||
@ -80,7 +81,7 @@ func (router *Router) AddProxyRouteToRuntime(endpoint *ProxyEndpoint) error {
|
||||
return errors.New("proxy endpoint not ready. Use PrepareProxyRoute before adding to runtime")
|
||||
}
|
||||
// Push record into running subdomain endpoints
|
||||
router.ProxyEndpoints.Store(endpoint.RootOrMatchingDomain, endpoint)
|
||||
router.ProxyEndpoints.Store(lookupHostname, endpoint)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -923,6 +923,7 @@ func ReverseProxyListDetail(w http.ResponseWriter, r *http.Request) {
|
||||
utils.SendErrorResponse(w, "epname not defined")
|
||||
return
|
||||
}
|
||||
epname = strings.ToLower(strings.TrimSpace(epname))
|
||||
endpointRaw, ok := dynamicProxyRouter.ProxyEndpoints.Load(epname)
|
||||
if !ok {
|
||||
utils.SendErrorResponse(w, "proxy rule not found")
|
||||
|
@ -41,7 +41,7 @@
|
||||
<div class="ui radio defaultsite checkbox">
|
||||
<input type="radio" name="defaultsiteOption" value="closeresp">
|
||||
<label>Close Connection<br>
|
||||
<small>Close the connection without any response</small>
|
||||
<small>Close the connection without any response or in TLS mode, send an empty response</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user