Open WROIATE opened 4 years ago
Hello, i've the same issue on my side. Did you find something new ?
package main
import (
"net/http"
"net/http/httputil"
"net/url"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.GET("/test/*proxyPath", ReverseProxy())
r.Run(":8080")
}
func ReverseProxy() gin.HandlerFunc {
target := "http://192.168.1.102:8081"
return func(c *gin.Context) {
// Extract the wildcard part of the original path
proxyPath := c.Param("proxyPath")
remote, err := url.Parse(target)
if err != nil {
panic(err)
}
// Modify the Director function to include the wildcard path
director := func(req *http.Request) {
req.URL.Scheme = remote.Scheme
req.URL.Host = remote.Host
req.URL.Path = remote.Path + "/" + proxyPath // Append the wildcard path
}
proxy := &httputil.ReverseProxy{Director: director}
proxy.ServeHTTP(c.Writer, c.Request)
}
} ```
That one has working on me
@manucorporat Can we close this issue?
Description
I have found the related issues: #1714 #686 And try to use the code in the issue, but I got the 404 error when the web broswer get the remote web static file with proxy, how to solve it?
How to reproduce
Expectations
Actual result