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

Closed
opened 2025-11-02 07:43:11 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @rubys on GitHub (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

Originally created by @rubys on GitHub (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_
GiteaMirror added the issue/needs-feedbackissue/not-a-bug labels 2025-11-02 07:43:11 -06:00
Author
Owner

@wxiaoguang commented on GitHub (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.

@wxiaoguang commented on GitHub (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.
Author
Owner

@rubys commented on GitHub (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
@rubys commented on GitHub (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 ```
Author
Owner

@wxiaoguang commented on GitHub (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 commented on GitHub (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> ...... ```
Author
Owner

@rubys commented on GitHub (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.

@rubys commented on GitHub (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](https://openvpn.net/), [radicale](https://radicale.org/3.0.html), 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`.
Author
Owner

@wxiaoguang commented on GitHub (Oct 15, 2021):

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.

@wxiaoguang commented on GitHub (Oct 15, 2021): 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.
Author
Owner

@rubys commented on GitHub (Oct 15, 2021):

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

@rubys commented on GitHub (Oct 15, 2021): Got it working, sorry for using the issue tracker for a support request. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7972