Go to file
kun c81f33b702 feat: support prometheus metrics in router 2021-03-19 12:24:47 +08:00
.circleci Fix typo 2020-02-20 21:48:55 +08:00
.github Create FUNDING.yml 2020-12-13 15:21:06 +08:00
contrib Added a contrib/goproxy.yml Stackfile for Docker Swarm deployment using Traefik 2019-01-14 11:32:10 +08:00
proxy feat: support prometheus metrics in router 2021-03-19 12:24:47 +08:00
renameio update go.mod to v2 2019-11-16 10:31:43 +08:00
robustio update go.mod 2019-12-04 09:29:53 +08:00
scripts fix (latest & list): 2018-12-26 21:14:10 +08:00
sumdb golint 2021-03-04 15:32:04 +08:00
test test: add a new test case 2021-03-04 10:58:13 +08:00
.gitignore Make sure lcean binary file by make clean 2020-03-12 14:31:33 +08:00
Dockerfile add tini for handling zombie processes 2020-11-17 09:47:00 +08:00
LICENSE Initial commit 2018-08-31 16:27:07 +08:00
Makefile refactor handlers 2019-07-25 16:20:01 +08:00
README.md Update README.md 2021-02-26 21:26:59 +08:00
docker-compose.yaml remove duplicate "goproxy" in docker-compose.yaml 2019-08-15 14:24:03 +08:00
go.mod feat: support prometheus metrics in router 2021-03-19 12:24:47 +08:00
go.sum feat: support prometheus metrics in router 2021-03-19 12:24:47 +08:00
main.go feat: support prometheus metrics in router 2021-03-19 12:24:47 +08:00

README.md

GOPROXY

CircleCI Go Report Card GoDoc

A global proxy for go modules. see: https://goproxy.io

Requirements

It invokes the local go command to answer requests.
The default cacheDir is GOPATH, you can set it up by yourself according to the situation.

Build

git clone https://github.com/goproxyio/goproxy.git
cd goproxy
make

Started

Proxy mode

./bin/goproxy -listen=0.0.0.0:80 -cacheDir=/tmp/test

If you run go get -v pkg in the proxy machine, should set a new GOPATH which is different from the old GOPATH, or mayebe deadlock. See the file test/get_test.sh.

Router mode

./bin/goproxy -listen=0.0.0.0:80 -proxy https://goproxy.io

Use the -proxy flag switch to "Router mode", which implements route filter to routing private module or public module .

                                         direct
                      +----------------------------------> private repo
                      |
                 match|pattern
                      |
                  +---+---+           +----------+
go get  +-------> |goproxy| +-------> |goproxy.io| +---> golang.org/x/net
                  +-------+           +----------+
                 router mode           proxy mode

In Router mode, use the -exclude flag set pattern , direct to the repo which match the module path, pattern are matched to the full path specified, not only to the host component.

./bin/goproxy -listen=0.0.0.0:80 -cacheDir=/tmp/test -proxy https://goproxy.io -exclude "*.corp.example.com,rsc.io/private"

Use docker image

docker run -d -p80:8081 goproxy/goproxy

Use the -v flag to persisting the proxy module data (change cacheDir to your own dir):

docker run -d -p80:8081 -v cacheDir:/go goproxy/goproxy

Docker Compose

docker-compose up

Appendix

  1. set export GOPROXY=http://localhost to enable your goproxy.
  2. set export GOPROXY=direct to disable it.