---
title: Installing and configuring reverse proxy for Grafana
slug: how-tos/Hzv6-custom
createdAt: 2025-09-22T13:00:40.130Z
---

This guide describes how to install and configure the Caddy webserver as proxy for Grafana.

## Caddy: webserver

### Download and install Caddy

Install packages needed for Caddy.

```bash
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
```

Add the Caddy repositories and its signing key to the server.

```bash
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg && curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
```

Install the Caddy webserver which routes traffic of the services on the server.

```bash
sudo apt update && sudo apt install -y caddy
```

Reload the system daemon, start Caddy and show the Caddy status to check if it's set to `active`.

```bash
sudo systemctl daemon-reload && sudo systemctl start caddy && sudo systemctl status caddy
```

### Configure Caddy

Open the Caddy configuration file and press `i` to be able to edit (insert) the file.

```bash
sudo vi /etc/caddy/Caddyfile
```

Replace its full content with the following:

```nginx
:443 {
    tls {
        alpn http1.1 h2
    }

    reverse_proxy http://localhost:3000
}
```

Press `ESC` to quit editing the file, and type `:wq` to save (write) and quit the file.

Validate the Caddy configuration to check if there is no `ERROR` listed. If an error occurred, see the [troubleshooting](docId\:Hzv6xWojQnCTwCthjRrJt) section.

```bash
sudo caddy validate --config /etc/caddy/Caddyfile
```

Stop and start caddy for the changes to take effect (intentionally no `restart` is used).

```bash
sudo systemctl stop caddy && sudo systemctl start caddy
```

At this point Caddy listens on `:443` but has no certificate yet, so HTTPS does not work. Next, [install a TLS certificate](docId\:r42agmz027IB-yUBHi4AG) to serve Grafana and Factry Historian over HTTPS.

## Troubleshooting

### Caddy failing to start

- Make sure validation does not return any errors:

```bash
sudo caddy validate --config /etc/caddy/Caddyfile
```

- Resolve the errors if there are some and stop and start Caddy again.

```bash
sudo systemctl stop caddy && sudo systemctl start caddy
```
