What's the recommended way to set up Grafana behind Caddy?


(Marko Mudrinić) #1

Hello y’all!

I’m working on setting up Grafana that will be behind Caddy. I want to setup something similar to Nginx’s proxy pass. For example, here is the Nginx config I have:

location / {
  	proxy_pass http://localhost:3000;
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection 'upgrade';
	proxy_set_header Host $host;
	proxy_cache_bypass $http_upgrade;
}

I created the following Caddyfile to do the same for me:

example.com {
        tls example@example.com
        gzip
        proxy / localhost:3000 {
                transparent
        }
}

What would you add or change in the current file, taking production use in the account? I seem to accomplish the same effect as with Nginx, but I would like to gather more opinions from the community.

Thank you very much.


Caddy and Grafana sub directory
(Matt Holt) #2

You might also want to add the websocket preset. That’ll proxy the Upgrade and Connection headers through.


(Marko Mudrinić) #3

Such as in the following example?

example.com {
        tls example@example.com
        gzip
        proxy / localhost:3000 {
                transparent
                websocket
        }
}

(Matt Holt) #4

Yup​​


(Marko Mudrinić) #5

Thank you very much Matt, this works flawless!


(Guillaume) #6

Hi, previous posts was not working for me, here is what’s working:

caddyFile

  proxy /metrics http://localhost:3000/ {
         without /metrics
         transparent
         websocket
  }

defaults.ini from Grafana

[server]
domain = mydomain.com
root_url = %(protocol)s://%(domain)s:/metrics

Cheers!


Caddy and Grafana sub directory