Gitea + IIS + local domain

Hello,

Gitea shows the message:
“The detected web site URL is “http://192.168.(…):3000/”, it’s unlikely matching the site config.
Mismatched app.ini ROOT_URL or reverse proxy “Host/X-Forwarded-Proto” config might cause wrong URL links for web UI/mail content/webhook notification/OAuth2 sign-in.”

When using Gitea, the following message appears: “cross-origin request detected, and/or browser is out of date: Sec-Fetch-Site is missing, and Origin does not match Host”

The server section in the app.ini file looks like this:
SSH_DOMAIN = gitea.local.domain
DOMAIN = gitea.local.domain

HTTP_PORT = 3000
HTTP_ADDR = 192.168.(…)

ROOT_URL = http://gitea.local.domain/
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = true
LFS_JWT_SECRET = (…)

APP_DATA_PATH = (…)
[lfs]
PATH = (…)

I am attaching the IIS settings (URL Rewrite on the Gitea site, “Server Proxy Settings” in “Application Request Routing” IIS).

What configuration errors could be causing these errors? Thank you

I had the same issue with Gitea behind IIS URL Rewrite.

Solution 1:
Access Gitea using HTTPS (https://xxxxx) instead of HTTP.

Solution 2:
If you must access Gitea through HTTP (without SSL), Sec-Fetch-Site may not be passed to Gitea. Add the following server variable in IIS:

Name:  HTTP_SEC_FETCH_SITE
Value: same-origin

web.config:


<rules useOriginalURLEncoding="false">
    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
        <match url="(.*)" />
        <action type="Rewrite" url="http://127.0.0.1:3000/{R:1}" />
        <serverVariables>
            <set name="HTTP_SEC_FETCH_SITE" value="same-origin" />
            <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="HTTP_ACCEPT_ENCODING" />
            <set name="HTTP_ACCEPT_ENCODING" value="" />
        </serverVariables>
    </rule>
</rules>

Additional IIS ARR Configuration Change

Edit:

C:\Windows\System32\inetsrv\config\applicationHost.config

Find the following line:
<proxy enabled="true" reverseRewriteHostInResponseHeaders="true" />

Change to:
<proxy enabled="true" preserveHostHeader="true" reverseRewriteHostInResponseHeaders="true" />

This ensures that Gitea receives the original host header and can correctly match the URL configured in ROOT_URL. As a result, the URL mismatch error should be resolved.