Last active
July 13, 2019 01:55
-
-
Save nanpuyue/9a2a83232d43d91f0577ddbcc15d6b21 to your computer and use it in GitHub Desktop.
simple reverse proxy service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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