# Caddy Server reverse proxy and Grafana in a subdirectory

**URL:** <https://community.grafana.com/t/caddy-server-reverse-proxy-and-grafana-in-a-subdirectory/14071>\
**Category:** Grafana\
**Created:** [February 1, 2019, 6:00am UTC](https://community.grafana.com/t/caddy-server-reverse-proxy-and-grafana-in-a-subdirectory/14071 "2019-02-01T06:00:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexandzors](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/alexandzors/32/5975_2.png) [@alexandzors](https://community.grafana.com/u/alexandzors)\
**Post date:** [February 1, 2019, 6:00am UTC](https://community.grafana.com/t/caddy-server-reverse-proxy-and-grafana-in-a-subdirectory/14071/1 "2019-02-01T06:00:32Z")

</div>

I am having trouble getting Grafana to work properly behind Caddy. Right now I have these settings:

grafana.ini:

```
#################################### Server ####################################
[server]
# Protocol (http, https, socket)
;protocol = http

# The ip address to bind to, empty will bind to all interfaces
;http_addr =

# The http port to use
;http_port = 3000

# The public facing domain name used to access grafana from a browser
domain = domain.net

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false

# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
root_url = http://domain.net/grafana

# Log web requests
;router_logging = false

# the path relative working path
;static_root_path = public

# enable gzip
;enable_gzip = false

# https certs & key file
;cert_file =
;cert_key =

# Unix socket path
;socket =

```

and Caddyfile:

```
domain.net {
        proxy /grafana/ http://10.9.9.132:3000 {
                without /grafana/
                transparent
                websocket
        }
}

```

which loads Grafana ([https://domain.net/grafana](https://domain.net/grafana)) fine but if I login it redirects back to my root domain which is blank. If I remove the without /grafana/ grafana “Loads” but no resources load and its just a blank dark grafana page.

So my question is. Does anyone here sucessfully use Grafana behind Caddy server reverse proxy?

Edit: Grafana is running in a docker container using grafana/grafana. v5.4.3  
Docker run command:

> docker run -d --user 1000 --volume “/home/alexander/grafana:/var/lib/grafana” --volume “/home/alexander/grafana/conf:/etc/grafana” -p 3000:3000 -e “GF\_SECURITY\_ADMIN\_PASSWORD=admin” -e “GF\_INSTALL\_PLUGINS=natel-influx-admin-panel,ryantxu-annolist-panel,jdbranham-diagram-panel,grafana-worldmap-panel,grafana-piechart-panel” grafana/grafana

---

<div class="post-metadata">

**Author:** ![yamila](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yamila/32/14490_2.png) [@yamila](https://community.grafana.com/u/yamila)\
**Post date:** [January 13, 2021, 9:59am UTC](https://community.grafana.com/t/caddy-server-reverse-proxy-and-grafana-in-a-subdirectory/14071/2 "2021-01-13T09:59:42Z")

</div>

Hi there! did you finally manage to solve this? I’m trying the same with small success so far.

I’m using docker-compose (v3.8), with this configuration:

```bash
  grafana:
    image: grafana/grafana:5.1.0
    environment:
      GF_SECURITY_ADMIN_USER: user 
      GF_SECURITY_ADMIN_PASSWORD: password 
      GF_SERVER_DOMAIN: my.company.io
      GF_SERVER_ROOT_URL: https://my.company.io/grafana/
      GF_SERVER_SERVE_FROM_SUB_PATH: "true"
    volumes:
      - grafana-storage:/var/lib/grafana
    ports:
      - "3000:3000"

```

And my caddyfile (caddy 2.0) running locally looks like:

```bash
my.company.io {
    tls internal
    log {
      output stdout
    }
    reverse_proxy /grafana/* 127.0.0.1:3000
}

```

(I’ve set locally [my.company.io](http://my.company.io) to localhost).

The output of caddy when I access to [https://my.company.io/grafana/](https://my.company.io/grafana/) is:

```console
2021/01/13 09:35:42.861 ERROR http.log.access.log0 handled request {"request": {"method": "GET", "uri": "/grafana/public/img/fav32.png", "proto": "HTTP/2.0", "remote
    _addr": "127.0.0.1:48440", "host": "my.company.io", "headers": {"Pragma": ["no-cache"], "Cache-Control": ["no-cache"], "User-Agent": ["Mozilla/5.0 (X11; Linux x86_64; rv: 84.0) Gecko/20100101 Firefox/84.0"], "Accept": ["image/webp,*/*"], "Accept-Language": ["es,en;q=0.5"], "Accept-Encoding": ["gzip, deflate, br"], "Dnt": ["1"], "Referer": ["https://my.company.io/grafana/"], "Cookie": ["_gcl_au=1.1.1221471365.1605163090; _ga_PNC23DP2NF=GS1.1.1610471995.148.0.1610471995.0; _ga=GA1.1.1012067630.1605163090; __ zlcmid=118jZzU3Cf9iCXf; grafana_sess=528c4ef6e8ad80ea; redirect_to=%252F"], "Te": ["trailers"]}, "tls": {"resumed": true, "version": 772, "ciphersuite": 4865, "proto": "h 2", "proto_mutual": true, "server_name": "my.company.io"}}, "common_log": "127.0.0.1 - - [13/Jan/2021:10:35:42 +0100] \"GET /grafana/public/img/fav32.png HTTP/2.0\" 404 1 0503", "duration": 0.004313732, "size": 10503, "status": 404, "resp_headers": {"Server": ["Caddy"], "Content-Type": ["text/html; charset=UTF-8"], "Date": ["Wed, 13 Jan 20 21 09:35:42 GMT"]}}

```

In the browser this is what I see:

![imagen](https://us1.discourse-cdn.com/grafana/original/2X/6/63d2975d324ad1ba1aba47d3cec4ef2ed717f42e.png)

Did I miss something? Could anyone give me a hint? Thanks in advance!
