How to configure grafana behind reverse proxy ingress nginx controller

I am struggling to setup grafana(v7.0.3) behind reverse proxy(nginx ingress controller nginx-ingress-controller:0.25.0) under dedicated path e.g . I deploy the prometheus and grafana using the prometheus operator helm chart (but it actually use the standard grafana helm chart as dependency)

Need help on how to configure grafana.ini and its Ingress object to make grafana accessible on http://MYHOST/grafana?

I tried to do exactly what mentioned in grafana but its not working - 502 Bad Gateway on any grafana query.

Any advice is welcome.

I found the solution.
You must use this in the grafana.ini root_url: ‘%(protocol)s://%(domain)s:%(http_port)s/grafana’ and not with hard coded setting of port. And also the port must be the internal port of grafana.

Installed kube-prometheus operator with Helm and modified values.yaml with recommended changes for Ingress URL. I have tried different options but still getting following message when I go to Any clues what else needs to be fixed?

**If you're seeing this Grafana has failed to load its application files**

1. This could be caused by your reverse proxy settings.

2. If you host grafana under subpath make sure your grafana.ini root_url setting 
 includes subpath. If not using a reverse proxy make sure to set 
 serve_from_sub_path to true.

3. If you have a local dev build make sure you build frontend using: yarn start, yarn 
start:hot, or yarn build

4. Sometimes restarting grafana-server can help

I see below settings in grafana.ini file inside Grafana pod.

check_for_updates = true
url =
mode = console
data = /var/lib/grafana/data
logs = /var/log/grafana
plugins = /var/lib/grafana/plugins
provisioning = /etc/grafana/provisioning
root_url =

Not sure why it worked only when I enabled serve_from_sub_path to true, but below values.yaml changes made Grafana work.

enabled: true
namespaceOverride: ""
# set pspUseAppArmor to false to fix Grafana pod Init errors
pspUseAppArmor: false
  #root_url: "%(protocol)s://%(domain)s/"
  serve_from_sub_path: true

## Deploy default dashboards.
defaultDashboardsEnabled: true

adminPassword: prom-operator

## If true, Grafana Ingress will be created
enabled: false

## Annotations for Grafana Ingress
annotations: {}
  # nginx
  # "true"

## Labels to be added to the Ingress
labels: {}

## Hostnames.
## Must be provided if Ingress is enable.
# hosts:
#   -

## Path for grafana ingress
path: /grafana/