goproxy / goproxy

A minimalist Go module proxy handler.

Home Page:https://pkg.go.dev/github.com/goproxy/goproxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

redirect from goproxy.io

Dereking opened this issue · comments

commented

I run a local goproxy at my server: goproxy -proxy=https://goproxy.io .

I created a golang test project, and set my $GOPROXY=mygoproxyweb, sine I run go build , I encountered a 302 redirect response from my goproxy:
Location https://goproxy.someimg.com/github.com/gin-gonic/gin/@v/v1.5.0.zip
It's very strange, I didn't find any string "someimg.com" in the goproxy code.

Is it a feature of product enviroment https://goproxy.io ?

I changed the upstream proxy to gocenter.io, It works well.
goproxy -proxy=https://gocenter.io .

Sorry, I didn't understand what you meant. It looks like you're not using this project. This project is a minimalist Go module proxy handler, not a binary file you can use directly. Maybe you asked the wrong project?

commented

I built this project and got a executable binary file goproxy. I think you are Chinese, here the Chinese:

我从这个项目编译了一个可执行文件。在服务器上运行:goproxy -proxy=https://goproxy.io
本地内网开发环境设置了$GOPROXY=mygoproxyweb
然后本地创建了一个测试golang项目,import 了github.com/gin-gonic/gin

本地go build时,mygoproxyweb 却返回了302响应(内网无法访问goproxy.someimg.com):
Location https://goproxy.someimg.com/github.com/gin-gonic/gin/@v/v1.5.0.zip

经测试:
本地访问 https://mygoproxyweb/github.com/gin-gonic/gin/@v/v1.5.0.zip 会被redirect 到goproxy.someimg.com
互联网访问 https://goproxy.io/github.com/gin-gonic/gin/@v/v1.5.0.zip 也会被redirect 到goproxy.someimg.com

我在https://github.com/goproxy/goproxy 源代码里没有找到 someimg.com . 难道这个是https://goproxy.io 的功能,并没有在代码里面?

commented

$ curl -v https://goproxy.io/github.com/gin-gonic/gin/@v/v1.5.0.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 119.28.201.50:443...

  • TCP_NODELAY set
  • Connected to goproxy.io (119.28.201.50) port 443 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
    ...........................(ssl)
  • Using HTTP2, server supports multi-use
  • Connection state changed (HTTP/2 confirmed)
  • Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
    } [5 bytes data]
  • Using Stream ID: 1 (easy handle 0xe41300)
    } [5 bytes data]

GET /github.com/gin-gonic/gin/@v/v1.5.0.zip HTTP/2
Host: goproxy.io
user-agent: curl/7.68.0
accept: /

{ [5 bytes data]

  • Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
    } [5 bytes data]
    < HTTP/2 302
    < server: nginx/1.16.1
    < date: Thu, 12 Mar 2020 11:27:26 GMT
    < content-type: text/html; charset=utf-8
    < content-length: 89
    < location: https://goproxy.someimg.com/github.com/gin-gonic/gin/@v/v1.5.0.zip
    <
    { [89 bytes data]
    100 89 100 89 0 0 640 0 --:--:-- --:--:-- --:--:-- 644Found.

  • Connection #0 to host goproxy.io left intact

你确定你在使用这个项目嘛?这个项目跟 goproxy.io 是无关的哦,如果你发现访问某些东西被 302 了那说明是他们的表现既如此,跟你具体怎么用是无关的。你也可以试试用 goproxy.cn 做上游,是不会出现任何 302 行为的。

此外,当前这个项目的使用方式是写代码哦:

package main

import (
	"net/http"

	"github.com/goproxy/goproxy"
)

func main() {
	http.ListenAndServe("localhost:8080", goproxy.New())
}

而不是编译,这个项目是一个可引入的三方库。

commented

ok~ 我试一下