Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use Apache HTTPd as a reverse proxy - missing content-type header #17310

Closed
rubys opened this issue Oct 14, 2021 · 6 comments
Closed

Can't use Apache HTTPd as a reverse proxy - missing content-type header #17310

rubys opened this issue Oct 14, 2021 · 6 comments
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea

Comments

@rubys
Copy link

rubys commented Oct 14, 2021

Gitea Version

Gitea version 1.15.4 built with GNU Make 4.1, go1.16.9 : bindata, sqlite, sqlite_unlock_notify

Git Version

git version 2.25.1

Operating System

Ubuntu 20.04

How are you running Gitea?

Downloaded from https://dl.gitea.io/gitea/1.15.4/gitea-1.15.4-linux-amd64

Database

MySQL

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Description

I'm trying to use Apache HTTPd as a reverse proxy, per https://docs.gitea.io/en-us/reverse-proxies/#apache-httpd-with-a-sub-path

Unfortunately, mod proxy html requires a valid content type header, per https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html#proxyhtmlenable

No such header is provided by gitea's main page:

$ curl --head https://try.gitea.io/
HTTP/2 200 
date: Thu, 14 Oct 2021 20:25:39 GMT
set-cookie: i_like_gitea=526e7410161b0b16; Path=/; HttpOnly; SameSite=Lax

P.S. I believe that the instructions are missing a ProxyHtmlEnable on.

Screenshots

No response

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Oct 15, 2021

Just tried, it returns a 302

I am not sure whether it is necessary to set content-type for a 302 response. I will check later and please advise.

@rubys
Copy link
Author

rubys commented Oct 15, 2021

That's odd; I'm still seeing a 200 response:

$ curl --head https://try.gitea.io/
HTTP/2 200
date: Fri, 15 Oct 2021 05:05:52 GMT
set-cookie: i_like_gitea=9058c2ceaf5cc63d; Path=/; HttpOnly; SameSite=Lax

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Oct 15, 2021

Do not use HEAD request.

I think the behavior is correct(at least,not wrong). If you feel something is wrong, please help to explain why it's wrong and what problem it causes.

$ curl --head -v 127.0.0.1:3000
*   Trying 127.0.0.1:3000...
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> HEAD / HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Set-Cookie: i_like_gitea=xxxxxx; Path=/; HttpOnly; SameSite=Lax
Set-Cookie: i_like_gitea=xxxxxx; Path=/; HttpOnly; SameSite=Lax
< Date: Fri, 15 Oct 2021 05:07:32 GMT
Date: Fri, 15 Oct 2021 05:07:32 GMT

<
* Connection #0 to host 127.0.0.1 left intact
$ curl -v 127.0.0.1:3000
*   Trying 127.0.0.1:3000...
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Content-Type: text/html; charset=utf-8
< Location: /explore/organizations
< Set-Cookie: i_like_gitea=xxxxxx; Path=/; HttpOnly; SameSite=Lax
< Set-Cookie: _csrf=xxxxxx; Path=/; Expires=Sat, 16 Oct 2021 05:07:45 GMT; HttpOnly; SameSite=Lax
< Set-Cookie: macaron_flash=; Path=/; Max-Age=0; HttpOnly; SameSite=Lax
< X-Frame-Options: SAMEORIGIN
< Date: Fri, 15 Oct 2021 05:07:45 GMT
< Content-Length: 45
<
<a href="/explore/organizations">Found</a>.

* Connection #0 to host 127.0.0.1 left intact
$ curl -v 127.0.0.1:3000/user/login
*   Trying 127.0.0.1:3000...
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> GET /user/login HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Set-Cookie: i_like_gitea=xxxxxx; Path=/; HttpOnly; SameSite=Lax
< Set-Cookie: _csrf=xxxxxx; Path=/; Expires=Sat, 16 Oct 2021 05:11:48 GMT; HttpOnly; SameSite=Lax
< Set-Cookie: macaron_flash=; Path=/; Max-Age=0; HttpOnly; SameSite=Lax
< X-Frame-Options: SAMEORIGIN
< Date: Fri, 15 Oct 2021 05:11:48 GMT
< Transfer-Encoding: chunked
<
<!DOCTYPE html>
......

@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Oct 15, 2021
@rubys
Copy link
Author

rubys commented Oct 15, 2021

OK.

I have a server. It runs Ubuntu 20.04 with Apache httpd. It serves various content, a few CGIs, and reverse proxy to openvpn, radicale, and a personal node.js application.

I tried adding gitea. The configuration is done in /etc/apache2/conf-enabled/gitea.conf:

AllowEncodedSlashes NoDecode

# Note: no trailing slash after either /git or port
ProxyPass /git http://localhost:3000 nocanon
ProxyPassReverse /git http://localhost:3000

What I find it the HTML returned is not adjusted, for example:

$curl -s http://localhost/git | tail -5
        <script src="/assets/js/index.js?v=a493805f36551bca156f633fe0e30c1c"></script>

</body>
</html>

When I run with a browser, I get a 404 when trying to fetch http://localhost/assets/js/index.js. And another 404 trying to fetch http://localhost/assets/css/index.css.

@wxiaoguang
Copy link
Contributor

You should use ROOT_URL in app.ini: https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini

Do not use ProxyPassReverse. If you see it, then the document should be updated.

@rubys
Copy link
Author

rubys commented Oct 15, 2021

Got it working, sorry for using the issue tracker for a support request. Thanks!

@rubys rubys closed this as completed Oct 15, 2021
@wxiaoguang wxiaoguang added the issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea label Oct 15, 2021
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea
Projects
None yet
Development

No branches or pull requests

2 participants