Creating a PR does not work with reverse proxy through IIS #720

Closed
opened 2025-11-02 03:34:04 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @Avalancs on GitHub (May 18, 2017).

  • Gitea version (or commit ref): 1.1.1
  • Git version: git 2.12.2.windows.2
  • Operating system: Windows Server 2016 standard
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

On our server I reverse-proxy outside users from https protocol throught IIS to Gitea running on localhost with http. I also use the HTTP_X_FORWARDED_HOST, HTTP_X_FORWARDED_SCHEMA and HTTP_X_FORWARDED_PROTO fields in the headers from the following documentation (I followed the steps from "IIS reverse proxy" section, and applied the same for Gitea) https://confluence.jetbrains.com/display/YTD65/Configuring+Proxy .

If I try to create a pull reques from a repository (that takes me to the url
https://(gitea url)/(organization)/(repo)/compare/master...master
) I get an HTTP404 response from IIS, but if I use Gitea from the server locally with the http local port it works just fine.

I will revert to using Gitea with the https protocol as it was meant to be. I actually needed IIS with reverse proxy for TeamCity and YouTrack because they would not handle SSL connections correctly, but Gitea works fine with HTTPS+certificate configured. But I am curious if anyone could provide some hint where to look, or if anyone is interested in this issue.

I also noticed yesterday that logs appear a few hours later in the gitea.log file, thus I am unable to provide logs right now. Maybe the output writer is buffered, or no flush operation is called?

Originally created by @Avalancs on GitHub (May 18, 2017). - Gitea version (or commit ref): 1.1.1 - Git version: git 2.12.2.windows.2 - Operating system: Windows Server 2016 standard - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [X] Not relevant - Log gist: ## Description On our server I reverse-proxy outside users from https protocol throught IIS to Gitea running on localhost with http. I also use the HTTP_X_FORWARDED_HOST, HTTP_X_FORWARDED_SCHEMA and HTTP_X_FORWARDED_PROTO fields in the headers from the following documentation (I followed the steps from "IIS reverse proxy" section, and applied the same for Gitea) https://confluence.jetbrains.com/display/YTD65/Configuring+Proxy . If I try to create a pull reques from a repository (that takes me to the url `https://(gitea url)/(organization)/(repo)/compare/master...master` ) I get an HTTP404 response from IIS, but if I use Gitea from the server locally with the http local port it works just fine. I will revert to using Gitea with the https protocol as it was meant to be. I actually needed IIS with reverse proxy for TeamCity and YouTrack because they would not handle SSL connections correctly, but Gitea works fine with HTTPS+certificate configured. But I am curious if anyone could provide some hint where to look, or if anyone is interested in this issue. I also noticed yesterday that logs appear a few hours later in the gitea.log file, thus I am unable to provide logs right now. Maybe the output writer is buffered, or no flush operation is called?
GiteaMirror added the type/bug label 2025-11-02 03:34:04 -06:00
Author
Owner

@lunny commented on GitHub (May 18, 2017):

Could you paste your log via gist?

@lunny commented on GitHub (May 18, 2017): Could you paste your log via gist?
Author
Owner

@bkcsoft commented on GitHub (May 19, 2017):

WRT logs not being written, do we need a "nothing has been written in X seconds, flush"-trigger?

@bkcsoft commented on GitHub (May 19, 2017): WRT logs not being written, do we need a "nothing has been written in X seconds, flush"-trigger?
Author
Owner

@Avalancs commented on GitHub (May 23, 2017):

I'm sorry, I might have got confused over what we call logs. By gist do we mean the terminal window where gitea runs, or the gitea.log? The log does not have text in it yet, but the terminal has the following:
(So I logged in with gitea user, opened the Organization named First, then the repository GiteaRep and clicked on pull request)

[Macaron] 2017-05-23 11:29:30: Started GET /user/login for 192.168.20.6:64011
[Macaron] 2017-05-23 11:29:30: Completed /user/login 200 OK in 13.0007ms
[Macaron] 2017-05-23 11:29:35: Started POST /user/login for 192.168.20.6:64011
[Macaron] 2017-05-23 11:29:35: Completed /user/login 302 Found in 134.0304ms
[Macaron] 2017-05-23 11:29:36: Started GET / for 192.168.20.6:64011
[Macaron] 2017-05-23 11:29:36: Completed / 200 OK in 71.9995ms
[Macaron] 2017-05-23 11:29:36: Started GET /avatars/2 for 192.168.20.6:64011
[Macaron] [Static] Serving /2
[Macaron] 2017-05-23 11:29:36: Completed /avatars/2 200 OK in 59.9994ms
[Macaron] 2017-05-23 11:29:36: Started GET /avatars/1 for 192.168.20.6:64011
[Macaron] [Static] Serving /1
[Macaron] 2017-05-23 11:29:36: Completed /avatars/1 200 OK in 62.9986ms
[Macaron] 2017-05-23 11:29:41: Started GET /org/First/dashboard for 192.168.20.6:64011
[Macaron] 2017-05-23 11:29:41: Completed /org/First/dashboard 200 OK in 59.0004ms
[Macaron] 2017-05-23 11:29:41: Started GET /avatars/1 for 192.168.20.6:64011
[Macaron] [Static] Serving /1
[Macaron] 2017-05-23 11:29:41: Completed /avatars/1 200 OK in 6.9979ms
[Macaron] 2017-05-23 11:29:43: Started GET /First/GiteaRep for 192.168.20.6:64011
[Macaron] 2017-05-23 11:29:44: Completed /First/GiteaRep 200 OK in 559.0017ms
[Macaron] 2017-05-23 11:29:44: Started GET /avatars/1 for 192.168.20.6:64011
[Macaron] [Static] Serving /1
[Macaron] 2017-05-23 11:29:44: Completed /avatars/1 200 OK in 6.9997ms
[Macaron] 2017-05-23 11:29:44: Started GET /plugins/highlight-9.6.0/github.css for 192.168.20.6:64011
[Macaron] 2017-05-23 11:29:44: Started GET /plugins/highlight-9.6.0/highlight.pack.js for 192.168.20.6:64011
[Macaron] [Static] Serving /plugins/highlight-9.6.0/github.css
[Macaron] 2017-05-23 11:29:44: Completed /plugins/highlight-9.6.0/github.css 200 OK in 22.001ms
[Macaron] [Static] Serving /plugins/highlight-9.6.0/highlight.pack.js
[Macaron] 2017-05-23 11:29:44: Completed /plugins/highlight-9.6.0/highlight.pack.js 200 OK in 119.9988ms
[Macaron] 2017-05-23 11:29:50: Started GET /First/GiteaRep/pulls for 192.168.20.6:64011
[Macaron] 2017-05-23 11:29:50: Completed /First/GiteaRep/pulls 200 OK in 460.0035ms
[Macaron] 2017-05-23 11:29:50: Started GET /avatars/1 for 192.168.20.6:64011
[Macaron] [Static] Serving /1
[Macaron] 2017-05-23 11:29:50: Completed /avatars/1 200 OK in 95.9993ms
[Macaron] 2017-05-23 11:29:53: Started GET /favicon.ico for 192.168.20.6:64011
[Macaron] 2017-05-23 11:29:53: Completed /favicon.ico 404 Not Found in 10.9991ms

@Avalancs commented on GitHub (May 23, 2017): I'm sorry, I might have got confused over what we call logs. By gist do we mean the terminal window where gitea runs, or the gitea.log? The log does not have text in it yet, but the terminal has the following: (So I logged in with gitea user, opened the Organization named First, then the repository GiteaRep and clicked on pull request) [Macaron] 2017-05-23 11:29:30: Started GET /user/login for 192.168.20.6:64011 [Macaron] 2017-05-23 11:29:30: Completed /user/login 200 OK in 13.0007ms [Macaron] 2017-05-23 11:29:35: Started POST /user/login for 192.168.20.6:64011 [Macaron] 2017-05-23 11:29:35: Completed /user/login 302 Found in 134.0304ms [Macaron] 2017-05-23 11:29:36: Started GET / for 192.168.20.6:64011 [Macaron] 2017-05-23 11:29:36: Completed / 200 OK in 71.9995ms [Macaron] 2017-05-23 11:29:36: Started GET /avatars/2 for 192.168.20.6:64011 [Macaron] [Static] Serving /2 [Macaron] 2017-05-23 11:29:36: Completed /avatars/2 200 OK in 59.9994ms [Macaron] 2017-05-23 11:29:36: Started GET /avatars/1 for 192.168.20.6:64011 [Macaron] [Static] Serving /1 [Macaron] 2017-05-23 11:29:36: Completed /avatars/1 200 OK in 62.9986ms [Macaron] 2017-05-23 11:29:41: Started GET /org/First/dashboard for 192.168.20.6:64011 [Macaron] 2017-05-23 11:29:41: Completed /org/First/dashboard 200 OK in 59.0004ms [Macaron] 2017-05-23 11:29:41: Started GET /avatars/1 for 192.168.20.6:64011 [Macaron] [Static] Serving /1 [Macaron] 2017-05-23 11:29:41: Completed /avatars/1 200 OK in 6.9979ms [Macaron] 2017-05-23 11:29:43: Started GET /First/GiteaRep for 192.168.20.6:64011 [Macaron] 2017-05-23 11:29:44: Completed /First/GiteaRep 200 OK in 559.0017ms [Macaron] 2017-05-23 11:29:44: Started GET /avatars/1 for 192.168.20.6:64011 [Macaron] [Static] Serving /1 [Macaron] 2017-05-23 11:29:44: Completed /avatars/1 200 OK in 6.9997ms [Macaron] 2017-05-23 11:29:44: Started GET /plugins/highlight-9.6.0/github.css for 192.168.20.6:64011 [Macaron] 2017-05-23 11:29:44: Started GET /plugins/highlight-9.6.0/highlight.pack.js for 192.168.20.6:64011 [Macaron] [Static] Serving /plugins/highlight-9.6.0/github.css [Macaron] 2017-05-23 11:29:44: Completed /plugins/highlight-9.6.0/github.css 200 OK in 22.001ms [Macaron] [Static] Serving /plugins/highlight-9.6.0/highlight.pack.js [Macaron] 2017-05-23 11:29:44: Completed /plugins/highlight-9.6.0/highlight.pack.js 200 OK in 119.9988ms [Macaron] 2017-05-23 11:29:50: Started GET /First/GiteaRep/pulls for 192.168.20.6:64011 [Macaron] 2017-05-23 11:29:50: Completed /First/GiteaRep/pulls 200 OK in 460.0035ms [Macaron] 2017-05-23 11:29:50: Started GET /avatars/1 for 192.168.20.6:64011 [Macaron] [Static] Serving /1 [Macaron] 2017-05-23 11:29:50: Completed /avatars/1 200 OK in 95.9993ms [Macaron] 2017-05-23 11:29:53: Started GET /favicon.ico for 192.168.20.6:64011 [Macaron] 2017-05-23 11:29:53: Completed /favicon.ico 404 Not Found in 10.9991ms
Author
Owner

@Avalancs commented on GitHub (May 23, 2017):

Okay, so it is possible to set IIS to display more information about an error:
https://blogs.msdn.microsoft.com/webtopics/2008/05/27/iis-7-0-http-error-pages/

now I got a more definitive error message: 404.7
It links a nice info page now: https://support.microsoft.com/hu-hu/help/942045/error-message-when-you-try-to-browse-a-web-page-that-is-hosted-on-iis-7.0-http-error-404.7-file-extension-denied
(sorry the error page was localized in Hungarian, and I was unable to tell IIS to show it in english, so I will not post a screenshot)

Basically IIS thought master...master is a file, and .master is an extension, and it does not allow opening arbitrary files by default. I'll try if I can find what is needed to disable this for this particular site.

@Avalancs commented on GitHub (May 23, 2017): Okay, so it is possible to set IIS to display more information about an error: https://blogs.msdn.microsoft.com/webtopics/2008/05/27/iis-7-0-http-error-pages/ now I got a more definitive error message: 404.7 It links a nice info page now: https://support.microsoft.com/hu-hu/help/942045/error-message-when-you-try-to-browse-a-web-page-that-is-hosted-on-iis-7.0-http-error-404.7-file-extension-denied (sorry the error page was localized in Hungarian, and I was unable to tell IIS to show it in english, so I will not post a screenshot) Basically IIS thought master...master is a file, and .master is an extension, and it does not allow opening arbitrary files by default. I'll try if I can find what is needed to disable this for this particular site.
Author
Owner

@Avalancs commented on GitHub (May 23, 2017):

The info page is disabling this check globally, so not a good solution... What I did was open up the site in IIS and under request filtering(?) I added .* to the allowed file extensions list, and removed the automatically added rejection to .master and it fixed the problem.

@Avalancs commented on GitHub (May 23, 2017): The info page is disabling this check globally, so not a good solution... What I did was open up the site in IIS and under request filtering(?) I added .* to the allowed file extensions list, and removed the automatically added rejection to .master and it fixed the problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#720