{"message":"remote unix:///tmp/ttyd.sock unreachable, could not forward: unsupported protocol scheme \"unix\""}
You could try
proxyConf := middleware.ProxyConfig{
// your other settings
Transport: &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
return net.Dial("unix", addr)
},
},
}
e.Use(middleware.ProxyWithConfig(proxyConf))
maybe it works.
panic: echo: proxy middleware requires balancer
goroutine 1 [running]:
github.com/labstack/echo/v4/middleware.ProxyWithConfig({0x1319698, {0x0, 0x0}, 0x0, 0x0, {0x0, 0x0}, {0x13641a0, 0xc00013d040}, 0x0})
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:214 +0x1aa
main.main()
/Users/matthias/apigw/server.go:62 +0x194
exit status 2
`
echo: http: panic serving [::1]:61352: runtime error: invalid memory address or nil pointer dereference
goroutine 6 [running]:
net/http.(*conn).serve.func1()
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:1801 +0xb9
panic({0x12b0840, 0x154adf0})
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/panic.go:1047 +0x266
net/http/httputil.NewSingleHostReverseProxy(0x0)
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/httputil/reverseproxy.go:144 +0x1d
github.com/labstack/echo/v4/middleware.proxyHTTP(0xc0000668a0, {0x13736f0, 0xc00018c460}, {0x1319778, {0x136a6a0, 0xc0000134e0}, 0x0, 0x0, {0x0, 0x0}, ...})
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:279 +0x45
github.com/labstack/echo/v4/middleware.ProxyWithConfig.func1.1({0x13736f0, 0xc00018c460})
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:260 +0x5d0
github.com/labstack/echo/v4.(*Echo).add.func1({0x13736f0, 0xc00018c460})
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/echo.go:552 +0x51
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000014fc0, {0x136a8e0, 0xc00017e2a0}, 0xc00019e000)
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/echo.go:662 +0x3bc
net/http.serverHandler.ServeHTTP({0xc0001917d0}, {0x136a8e0, 0xc00017e2a0}, 0xc00019e000)
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:2878 +0x43b
net/http.(*conn).serve(0xc00018c3c0, {0x136bb00, 0xc0001916e0})
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:1929 +0xb08
created by net/http.(*Server).Serve
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:3033 +0x4e8
when proxying multiple things like:
serverA -> /
serverB -> /api
can I make serverA not overwrite serverB on /api? Because I can't figure it out haha
question. I am trying to add a custom middleware which changes both method and path (I know there are existing middlewares for both and I checked their source)
req := c.Request()
req.Method = "PUT"
path := req.URL.Path
url, _ := req.URL.Parse(path + "/9")
req.URL = url
This succeeds in changing the method, but it fails changing the path, any idea what's up with that?
I am facing the "No token found " when I try to use echo framework for expositioning my metrics and using prometheus to scrape them.
While instrumenting my labstack echo web server with prometheus, I followed the example here: https://echo.labstack.com/middleware/prometheus/
and didnt instrument any custom metrics yet, still not able to get it to work with prometheus scraper with just the basic echo framework metrics. Following is the scrape config that I used:
- job_name: 'nebula-staging'
static_configs:
- targets: ['10.X.Y.Z:8000']
labels:
instance: 'nebula'
Also, I am able to curl to this address and get the metrics, when I use promtool to check the metrics for any inconsistency I dont find any. Not too sure what to do, does anyone have any clue? Would be of great help, thanks!
Hi, I have been stuck trying to configure my echo app to serve with https, but have no success. I've read and tried this: https://echo.labstack.com/cookbook/auto-tls ..
So at this point i am getting following error:
echo: http: TLS handshake error from {some-ip}:27002: acme/autocert: unable to satisfy "https://acme-v02.api.letsencrypt.org/acme/authz-v3/53188301650" for domain "mydomain.com": no viable challenge type found
func GETTER(path string, params []string, paramValues []string) string {
e := echo.New()
req := httptest.NewRequest(http.MethodGet, path, nil)
rec := httptest.NewRecorder()
c := e.NewContext(req, rec)
c.SetParamNames(params...)
//res := rec.Result()
defer rec.Result().Body.Close()
c.SetParamValues(ClientIdString)
//controllers.GetFullProfile(c)
return rec.Body.String()
}
func login(c echo.Context) error {
validate := validator.New()
u := new(Auth)
if err := c.Bind(u); err != nil {
return echo.NewHTTPError(http.StatusBadRequest)
}
err := validate.Struct(u)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest)
}
user , err := domain.GetAuthByUsername(u.Username,u.Password)
if user.Id == 0 {
return echo.ErrUnauthorized
}
claims := &jwtCustomClaims{ user.Username,*user.Active,*user.Admin,user.Roles,
jwt.StandardClaims{
ExpiresAt: time.Now().Add(time.Hour * 72).Unix(),
},
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
t, err := token.SignedString([]byte(os.Getenv("ACCESS_SECRET")))
if err != nil {
return err
}
return c.JSON(http.StatusOK, echo.Map{
"token": t,"roles":user.Roles,"username": user.Username,
})
}
func startAuthRouters(app *echo.Echo){
auth := app.Group("/auth/login")
auth.POST("", login)
}