elazarl / goproxy

An HTTP proxy library for Go
BSD 3-Clause "New" or "Revised" License
6.06k stars 1.1k forks source link

Can I proxy request to another host? #455

Open fallenleavesguy opened 2 years ago

fallenleavesguy commented 2 years ago

Can I proxy request to another host? If URL match some rules, just access host2.com and return the response of host2.com when user is accessing host1.com.

CoolSpring8 commented 2 years ago

Yes, I think you can just modify req.Host in your handler.

suxianbaozi commented 2 years ago

add handler. and return a new Response