How to Use IIS with URL Rewrite as a Reverse Proxy for Grafana on Windows
Example:
- Parent site: http://localhost:8080
If you have not already done it, then a requirement is to install URL Rewrite module for IIS.
Download and install the URL Rewrite module for IIS:
The Grafana config can be set by creating a file named in the conf
subdirectory of your Grafana installation. See the installation instructions for more details.
Given that the subpath should be grafana
and the parent site is localhost:8080
then add this to the custom.ini
config file:
Restart the Grafana server after changing the config file.
- Open the IIS Manager and click on the parent website
- In the admin console for this website, double click on the Url Rewrite option:
Click on the
Add Rule(s)…
actionChoose the Blank Rule template for an Inbound Rule
Create an Inbound Rule for the parent website (localhost:8080 in this example) with the following settings:
- pattern:
grafana(/)?(.*)
- check the
Ignore case
checkbox - check the checkbox
- check the
Stop processing of subsequent rules
checkbox
- pattern:
Finally, navigate to (replace
http://localhost:8080
with your parent domain) and you should come to the Grafana login page.
- the pattern for the Inbound Rule is incorrect. Edit the rule, click on the
Test pattern…
button, test the part of the url afterand make sure it matches. For
grafana/login
the test should return 3 capture groups: {R:0}: {R:1}:/
and {R:2}:login
. - The
root_url
setting in the Grafana config file does not match the parent url with subpath.
Grafana Website only shows text with no images or css
- The
root_url
setting in the Grafana config file does not match the parent url with subpath. This could happen if the root_url is commented out by mistake (;
is used for commenting out a line in .ini files):
; root_url = %(protocol)s://%(domain)s/grafana/
- or if the subpath in the
root_url
setting does not match the subpath used in the pattern in the Inbound Rule in IIS:
root_url = %(protocol)s://%(domain)s/grafana/
pattern in Inbound Rule:
- or if the Rewrite Url in the Inbound Rule is incorrect.
The Rewrite Url should not include the subpath.
The Rewrite Url should contain the capture group from the pattern matching that returns the part of the url after the subpath. The pattern used above returns 3 capture groups and the third one {R:2} returns the part of the url after http://localhost:8080/grafana/
.