GOPROXY protocol support #3668

Closed
opened 2025-11-02 05:21:10 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @lunny on GitHub (Jul 25, 2019).

If gitea could be as a goproxy server and all requested repositories could be stored on a special orgnization. That maybe a good idea.

ref: https://go.dev/ref/mod#goproxy-protocol

Originally created by @lunny on GitHub (Jul 25, 2019). If gitea could be as a goproxy server and all requested repositories could be stored on a special orgnization. That maybe a good idea. ref: https://go.dev/ref/mod#goproxy-protocol
GiteaMirror added the type/featuretype/proposal labels 2025-11-02 05:21:10 -06:00
Author
Owner

@lunny commented on GitHub (Aug 8, 2019):

The benefit when gitea support goproxy protocol but not a third-party:

  • all the information saved already in gitea(almost tags list, go mod file, source zip)
  • private repositories support. No proxy will save your token or private repositories copy.
  • if you have mirrored many packages from github, it could be goproxy resouces since we know which repositories you mirrored from.

A goproxy protocol request likes below, there are 5 http requests need to be implemented.

GET $HOST:$PORT/gitea.com/gitea/gitea/@v/list
GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.info
GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.mod
GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.zip
GET $HOST:$PORT/gitea.com/gitea/gitea/@latest

If gitea supports that, the domain gitea.com will be a reserved username.

refs:
https://research.swtch.com/vgo-module
https://docs.gomods.io/intro/protocol/

btw:
Since go1.13 will support multiple goproxies, this will be possible.

@lunny commented on GitHub (Aug 8, 2019): The benefit when gitea support goproxy protocol but not a third-party: - [ ] all the information saved already in gitea(almost tags list, go mod file, source zip) - [ ] private repositories support. No proxy will save your token or private repositories copy. - [ ] if you have mirrored many packages from github, it could be goproxy resouces since we know which repositories you mirrored from. A goproxy protocol request likes below, there are 5 http requests need to be implemented. ``` GET $HOST:$PORT/gitea.com/gitea/gitea/@v/list GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.info GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.mod GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.zip GET $HOST:$PORT/gitea.com/gitea/gitea/@latest ``` If gitea supports that, the domain `gitea.com` will be a reserved username. refs: https://research.swtch.com/vgo-module https://docs.gomods.io/intro/protocol/ btw: Since go1.13 will support multiple goproxies, this will be possible.
Author
Owner

@lafriks commented on GitHub (Aug 8, 2019):

but problem is that pretty much any domain will have to be reserved username then...

@lafriks commented on GitHub (Aug 8, 2019): but problem is that pretty much any domain will have to be reserved username then...
Author
Owner

@sapk commented on GitHub (Aug 8, 2019):

And what it would do with external package (not a local repo) ? cache them also ?
From an architecture point, I feel that it would be better to use one of the many goproxy implementation since it would be better to setup it under another domain like goproxy.domain.com. Furtermore, one of the goal of the goproxy is to act as a cache in case of downtime of repo, implentating goproxy in gitea would lost this advantage.

@sapk commented on GitHub (Aug 8, 2019): And what it would do with external package (not a local repo) ? cache them also ? From an architecture point, I feel that it would be better to use one of the many goproxy implementation since it would be better to setup it under another domain like goproxy.domain.com. Furtermore, one of the goal of the goproxy is to act as a cache in case of downtime of repo, implentating goproxy in gitea would lost this advantage.
Author
Owner

@lunny commented on GitHub (Aug 8, 2019):

@lafriks No. Only the domain gitea itself. Mirrors could be any place because we know they mirrored from.

@lunny commented on GitHub (Aug 8, 2019): @lafriks No. Only the domain gitea itself. Mirrors could be any place because we know they mirrored from.
Author
Owner

@lunny commented on GitHub (Aug 8, 2019):

@sapk there are two functionality of goproxy protocol. One is for cache, another is for repositories.
Before go module come, go will get packages via go get that we only needs to provide a meta and a VCS(git) protocol.

On go module time, above is also available but provide a direct protocol is better. It will accelerate directly visit because git is too slow for a go module protocol.

You can consider this is a go module protocol v2 rather than go get protocol v1.

This will not against goproxy, it will only provide repositories via goproxy protocol.

@lunny commented on GitHub (Aug 8, 2019): @sapk there are two functionality of goproxy protocol. One is for cache, another is for repositories. Before go module come, go will get packages via go get that we only needs to provide a meta and a VCS(git) protocol. On go module time, above is also available but provide a direct protocol is better. It will accelerate directly visit because git is too slow for a go module protocol. You can consider this is a go module protocol v2 rather than go get protocol v1. This will not against goproxy, it will only provide repositories via goproxy protocol.
Author
Owner

@lunny commented on GitHub (Aug 8, 2019):

When I and unknwon begin gopm repository on 2014 or 2015. We download github's zip or tar.gz source packages but not via git protocol. It's faster than go get that time. The goproxy is similiar.

@lunny commented on GitHub (Aug 8, 2019): When I and unknwon begin `gopm` repository on 2014 or 2015. We download github's `zip` or `tar.gz` source packages but not via git protocol. It's faster than `go get` that time. The goproxy is similiar.
Author
Owner

@sapk commented on GitHub (Aug 8, 2019):

@lunny I understand the speed-up but the trade-off are "big" (blocking some name, adding complexity, ...) compare to someone just setup a goproxy aside.
And for blocking name, technically module are not necessary FQDN at the base so it can interfere with a lot of other url. I think we better try to offer api endpoint (if needed) and work with goproxy implementation to help them speed there inital search on gitea.

On a side note, I haven't tested but GOPROXY should support a subfolder like GOPROXY=https://myproxy.com/sub-folder. (at least, it support it for file:// url) confirmed and confirmed
If we implement goproxy, I think it would be better to offer a sub-folder as an endpoint.

@sapk commented on GitHub (Aug 8, 2019): @lunny I understand the speed-up but the trade-off are "big" (blocking some name, adding complexity, ...) compare to someone just setup a goproxy aside. And for blocking name, technically module are not necessary FQDN at the base so it can interfere with a lot of other url. I think we better try to offer api endpoint (if needed) and work with goproxy implementation to help them speed there inital search on gitea. On a side note, I haven't tested but GOPROXY should support a subfolder like GOPROXY=https://myproxy.com/sub-folder. (at least, it support it for file:// url) [confirmed](https://github.com/golang/go/blob/24e5fae92e2c971fa30ac170b7656ff14f3cfde5/src/cmd/go/testdata/mod/README#L17) and [confirmed](https://github.com/golang/go/blob/4b41f7f8188ce8f711cacd3097a2cb02af5c333c/src/cmd/go/internal/modfetch/proxy.go#L81) If we implement goproxy, I think it would be better to offer a sub-folder as an endpoint.
Author
Owner

@lafriks commented on GitHub (Aug 8, 2019):

we could set to reserved username registry to use for goproxy, maybe later also for npm, docker registries etc, so that it could be used with GOPROXY=https://gitea.com/registry/go/ and for others we could use https://gitea.com/registry/npm/ etc

@lafriks commented on GitHub (Aug 8, 2019): we could set to reserved username `registry` to use for goproxy, maybe later also for npm, docker registries etc, so that it could be used with `GOPROXY=https://gitea.com/registry/go/` and for others we could use `https://gitea.com/registry/npm/` etc
Author
Owner

@lunny commented on GitHub (Aug 9, 2019):

@sapk @lafriks Yeah. Gitea could implement these package protocols for this instance's repositories (NOT for a cache proxy). The target is different from goproxy or athens . And as what @lafriks said, this should be a first step to support golang, furthermore we can support other language packages protocols.

For enterprises' public or private repositories, that will reduce an extra server(goproxies or other languages).

Once gitea implemented this and with go 1.13, we can just set GOPROXY=https://myenterprise.com/registry/go,https://goproxy.io

@lunny commented on GitHub (Aug 9, 2019): @sapk @lafriks Yeah. Gitea could implement these package protocols for this instance's repositories (NOT for a cache proxy). The target is different from goproxy or athens . And as what @lafriks said, this should be a first step to support golang, furthermore we can support other language packages protocols. For enterprises' public or private repositories, that will reduce an extra server(goproxies or other languages). Once gitea implemented this and with go 1.13, we can just set `GOPROXY=https://myenterprise.com/registry/go,https://goproxy.io`
Author
Owner

@s3rj1k commented on GitHub (Apr 6, 2023):

Highly needed feature

@s3rj1k commented on GitHub (Apr 6, 2023): Highly needed feature
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3668