Grafana with nginx reverse proxy

I want to access grafana with nginx reverse proxy which is on different server.
Here are the changes in grafana.ini

;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


 location ^~ /grafana {
                    #rewrite ^/grafana/(.*)$ /$1 break;
                    proxy_pass http://*.*.*.*:3000;
                    proxy_http_version 1.1;
                    proxy_set_header   Connection        'upgrade';
                    proxy_set_header   Upgrade           $http_upgrade;
                    proxy_set_header   Host              $host;
                    proxy_set_header   X-Real-IP         $remote_addr;
                    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
                    proxy_set_header   X-Forwarded-Proto $scheme;
                    proxy_set_header Authorization "";
                    proxy_max_temp_file_size 0;


logger=context userId=0 orgId=0 uname= t=2023-01-16T11:14:43.002626662Z level=info msg="Request Completed" method=GET path=/grafana status=302 remote_addr= time_ms=0 duration=409.347µs size=29 referer= handler=notfound

if i am setting the location in nginx.conf to / without subpath i am able to access it. but with /grafana getting this error in grafan.log

Hi @neelam,

Thanks for the feedback. Yes, this seems a configuration problem on the Nginx side.

I found this similar post where the error code is the same as yours and it also contains a solution. Please check it out as it should help you in the resolution.

Also, this is the guide link I am currently using on my local machine. It might also give you some more useful hints (e.g. how to check and validate the configuration files, adding hostname in /etc/hosts etc).

I hope this helps.

Yes I did the the steps mentioned in the document. Since nginx is on a different server and I’ve a domain name for it. I’ve not given domain name on grafana side. I’ve added the subpath to root url. If i change location of nginx to / it works fine. But with /grafana I’m getting a 404