wip
This commit is contained in:
39
xtest/main.go
Normal file
39
xtest/main.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := gin.Default()
|
||||
|
||||
app.Any("/*any", func() gin.HandlerFunc {
|
||||
link := "http://dev.pro.bifrost.com"
|
||||
host := "dev.pro.bifrost.com"
|
||||
url, oe := url.Parse(link)
|
||||
if oe != nil {
|
||||
log.Fatal("url parse err:", oe)
|
||||
}
|
||||
|
||||
//ps := httputil.NewSingleHostReverseProxy(url)
|
||||
//ps.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
|
||||
|
||||
ps := httputil.ReverseProxy{
|
||||
Rewrite: func(r *httputil.ProxyRequest) {
|
||||
r.SetURL(url)
|
||||
r.Out.Header.Set("Host", host)
|
||||
r.In.Header.Set("Host", host)
|
||||
},
|
||||
}
|
||||
|
||||
return func(c *gin.Context) {
|
||||
c.Request.Header.Set("Host", host)
|
||||
ps.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
}())
|
||||
|
||||
log.Fatal(app.Run(":9091"))
|
||||
}
|
Reference in New Issue
Block a user