Skip to content

Instantly share code, notes, and snippets.

@nanpuyue
Last active July 13, 2019 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanpuyue/9a2a83232d43d91f0577ddbcc15d6b21 to your computer and use it in GitHub Desktop.
Save nanpuyue/9a2a83232d43d91f0577ddbcc15d6b21 to your computer and use it in GitHub Desktop.
simple reverse proxy service
// date: 2019-07-12
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <nanpuyue@gmail.com> https://blog.nanpuyue.com
package main
import (
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
upstream, _ := url.Parse("http://127.0.0.1:80")
httputil.NewSingleHostReverseProxy(upstream).ServeHTTP(w, r)
})
log.Println(http.ListenAndServe(":8080", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment