nginx 配置反向代理 grafana

一、修改 grafana 配置文件内的

1、domain=自己的域名;

2、root_url 最后添加 /grafana/

3、server-from_sub_path = true

注意:需要去掉行前的 ; 号    “;”符号是注释

 nginx 配置反向代理 grafana_第1张图片

二、重启 grafana   

systemctl restart grafana-server

三、配置nginx.conf  grafana信息

注意:因为之前修改grafana.ini配置文件时 root_url 最后添加的是 /grafana/    所以 nginx.conf 内 location最后也要加上 /

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    
    # 负载均衡配置
    upstream tomcat {
        server 127.0.0.1:8000;
	# server 127.0.0.1:8000; # 多台服务器时可填写多台ip:port
    }
    upstream grafana {
        server 127.0.0.1:3000;
    }
    
    server {
        listen       80;
        server_name  www.自己的域名 自己的域名;
        charset utf-8;
        client_body_buffer_size 10M;
		proxy_redirect     off;
		proxy_set_header   Host             $host:$server_port;
		proxy_set_header   X-Real-IP        $remote_addr;
		proxy_set_header X-Forwarded-Host $host:$server_port;
		proxy_set_header X-Forwarded-Server $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
		
        location / {
            root   html;
            index  index.html index.htm;
        }	

        location /grafana/ {
            proxy_pass http://grafana;
            proxy_redirect default;
            proxy_set_header   Host             $host:$server_port;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header X-Forwarded-Host $host:$server_port;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

四、检查NGINX配置  重启NGINX服务

nginx -t 
nginx -s reload

五、浏览器打开   域名/grafana  即可访问

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(linux,nginx)