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 MYHOST.com/grafana . 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 Run Grafana behind a reverse proxy | Grafana Labs but its not working - 502 Bad Gateway on any grafana query.

Any advice is welcome.

Update
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.

Hi,
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 mysb.grafanasite.com. 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.

[analytics]
check_for_updates = true
[grafana_net]
url = https://grafana.net
[log]
mode = console
[paths]
data = /var/lib/grafana/data
logs = /var/log/grafana
plugins = /var/lib/grafana/plugins
provisioning = /etc/grafana/provisioning
[server]
root_url = https://mysb.grafanasite.com/

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

grafana:
enabled: true
namespaceOverride: ""
# set pspUseAppArmor to false to fix Grafana pod Init errors
rbac:
pspUseAppArmor: false
grafana.ini:
server:
  domain: mysb.grafanasite.com
  #root_url: "%(protocol)s://%(domain)s/"
  root_url: https://mysb.grafanasite.com/grafana/
  serve_from_sub_path: true

## Deploy default dashboards.
##
defaultDashboardsEnabled: true

adminPassword: prom-operator

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

## Annotations for Grafana Ingress
##
annotations: {}
  # kubernetes.io/ingress.class: nginx
  # kubernetes.io/tls-acme: "true"

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

## Hostnames.
## Must be provided if Ingress is enable.
##
# hosts:
#   - grafana.domain.com
hosts:
  - mysb.grafanasite.com

## Path for grafana ingress
path: /grafana/

Can you pls share the code it would be really helpful to know the complete setup
Thank you