Skip to content

Proxy middleware - unreachable, could not forward: net/http: HTTP/1.x transport connection broken #2243

@ddhvn

Description

@ddhvn

Issue Description

Use function Skipper in middleware.ProxyConfig{} to skip the middleware with some conditions, It does not work when getting value from request body of echo.Context.

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

The request is forwarded to targets when using request body of echo.Context

Working code to debug

e.Use(middleware.ProxyWithConfig(middleware.ProxyConfig{
		Skipper: func(c echo.Context) bool {
			if c.Request().URL.Path != "/api/order/create" {
				return true
			}
			serviceID := c.FormValue("service_id") // if this line is removed, the proxy works, otherwise got the error below
			// check condition with serviceID...
		
			return false
		},
		Balancer: middleware.NewRoundRobinBalancer(targets),
		Rewrite: map[string]string{
			"/api/order/create": "/api/saas/order/create",
		},
	}))

Got Error

"internal": "code=502, message=remote order-wrapper(http://localhost:9091) unreachable, could not forward: net/http: HTTP/1.x transport connection broken: http: ContentLength=1750 with Body length 0",

Version/commit

Echo version: github.com/labstack/echo/v4 v4.1.17
Go version: 1.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions