Skip to content

Instantly share code, notes, and snippets.

Last active Aug 30, 2018
What would you like to do? Reverse Proxy in Go
package main
import (
var (
origin, _ = url.Parse("")
func main() {
originProxy := httputil.NewSingleHostReverseProxy(origin)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
http.Redirect(w, r, "/wiki/Anasayfa", http.StatusMovedPermanently)
r.Host = origin.Host
originProxy.ServeHTTP(w, r)
log.Fatal(http.ListenAndServe(":8080", nil))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment