go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.02k stars 5.49k forks source link

bad line length character: <htm #21810

Closed kingchun closed 1 year ago

kingchun commented 1 year ago

Description

I will encounter this error when I execute push when using nginx reverse proxy

Enumerating objects: 492, done.
Counting objects: 100% (492/492), done.
Delta compression using up to 12 threads
Compressing objects: 100% (414/414), done.
Writing objects: 100% (492/492), 229.61 KiB | 229.61 MiB/s, done.
Total 492 (delta 59), reused 492 (delta 59), pack-reused 0
fatal: protocol error: bad line length character: <htm
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly

nginx log

[error] 27114#0: *217529 attempt to set status 403 via ngx.exit after sending out the response status 200, client: 1.1.1.1, server: ww.www, request: "POST /lingling/text66.git/git-receive-pack HTTP/2.0"

Gitea Version

1.17.1 built with GNU Make 4.1, go1.18.5 : bindata, sqlite, sqlite_unlock_notify

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

Nov 14 21:46:37 lingling gitea[27307]: 2022/11/14 21:46:37 [637246bd] router: completed GET /lingling/text66.git/info/refs?service=git-receive-pack for 2.56.255.82:0, 401 Unauthorized in 3.3ms @ repo/http.go:532(repo.GetInfoRefs) Nov 14 21:46:37 lingling gitea[27307]: 2022/11/14 21:46:37 ...dules/git/command.go:153:Run() [D] [637246bd-2] /var/lib/gitea/data/gitea-repositories/lingling/text66.git: /usr/bin/git -c credential.helper= -c filter.lfs.required= -c filte Nov 14 21:46:37 lingling gitea[27307]: 2022/11/14 21:46:37 [637246bd-2] router: completed GET /lingling/text66.git/info/refs?service=git-receive-pack for 2.56.255.82:0, 200 OK in 26.1ms @ repo/http.go:532(repo.GetInfoRefs) No response

Screenshots

No response

Git Version

2.17.1

Operating System

ubuntu 18

How are you running Gitea?

I am running the official downloaded binaries through systemctl

Database

MySQL

kingchun commented 1 year ago

This problem doesn't occur when I don't use a reverse proxy

lunny commented 1 year ago

It should be a reverseproxy configuration problem.

kingchun commented 1 year ago

应该是reverseproxy配置问题。

我是按照官方文档配置的反向代理 我也不知道为啥 老哥可以看看你的配置吗

kingchun commented 1 year ago

反向代理配置如下

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
wxiaoguang commented 1 year ago

ngx.exit is a Lua method.

Check your nginx config. Or, please provide a simple reproducible demo for debugging purpose.

It doesn't seem to be a Gitea problem.