reverse proxy

This commit is contained in:
Kulvir Singh
2025-10-15 13:45:16 +05:30
parent 9d3b3b7940
commit 2ff2e4ffb3
2 changed files with 31 additions and 0 deletions

View File

@@ -59,3 +59,19 @@ We can setup seperate error pages for different kind of error. But I'll be using
For reference look at [error.html](./error.html) file.
To learn more about it check the Caddy docs **RTFM** about [handling errors](https://caddyserver.com/docs/caddyfile/directives/handle_errors).
## Reverse Proxy
**Most of the devs don't know what reverse proxy is. So maybe [check this](https://en.wikipedia.org/wiki/Reverse_proxy) out.**
Lets say we have `pokemon` API running on PORT `8080` and we want any traffic coming to subdomain `pokemon.domain-name.com` to be redirected to the pokemon server.
To achieve this we can setup reverse proxy for this subdomain.
To setup reverse proxy first we need to set `A Record` of sub-domain to the IP address of the VPS.
Then we can define the reverse proxy in our caddy config like mentioned below.
```Caddyfile
pokemon.domain-name.com {
reverse_proxy :8080
}
```
Checkout this sample reverse proxy [config](./pokemon.Caddyfile) and ofc read [caddy docs](https://caddyserver.com/docs/quick-starts/reverse-proxy) to check what else you can do with reverse proxy.