Use IIS with URL Rewrite as a reverse proxy - ERR_TOO_MANY_REDIRECTS

Hello people,
I’ve been trying to configure the Grafana on IIS using reverse proxy but without success.
I followed the steps in the documentation ( Use IIS with URL Rewrite as a reverse proxy | Grafana Labs) and watch a tutorial (Grafana and IIS - Windows Server Installation Setup and Configuration - YouTube), but, I always have the error ERR_TOO_MANY_REDIRECTS in the browser.

Grafana version: 10.0.1.

My custom.ini config:

[server]
# Protocol (http, https, h2, socket)
protocol = http

# The ip address to bind to, empty will bind to all interfaces
;http_addr =

# The http port  to use
http_port = 8080

# The public facing domain name used to access grafana from a browser
domain = localhost

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false

# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/

# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
serve_from_sub_path = true

My web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Grafana Inbound Rule" enabled="true" stopProcessing="true">
                    <match url="grafana(/)?(.*)" />
                    <action type="Rewrite" url="http://localhost:8080{R:2}" logRewrittenUrl="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

I don’t know what happens so I need help.
Thanks

Welcome @byander

Why do you want to run grafana via IIS ?

Hello @yosiasz ,
It’s because currently, the company where I work uses only Windows Servers. Unfortunately, for now, I can’t use Linux Server.

I found on Github this issue (Azure AD redirect not working behind IIS reverse proxy · Issue #32034 · grafana/grafana · GitHub) and I put in the “Server proxy settings” and then configure ARR the option “Reverse Proxy” with the value “localhost:3000”.

The default value is empty and the documentation doesn’t mention this field to set.

When I set it to localhost:3000, it works but I don’t know if is the best way to solve it.

1 Like

why not install it as a windows service?

install as service
start
done

sc.exe create _grafana-10.0.0 binpath= C:\LGTM\grafana-10.0.0\bin\grafana-server.exe

image

@yosiasz ,
I installed it as a service.
But I would like to use the proxy reverse from IIS to Grafana service and this way hide the port from URL.

do you have anything running on 80? on that server

or maybe bypass IIS and use this? been a while since I have done this