This page is about Caddy 2, which is currently in beta. Click here for the old Caddy 1 site. Thank you for your patience as we transition!
Documentation
Caddy 2 is beta software. It is ready for production, but some things will change between releases; check the release notes before upgrading.

Reverse proxy quick-start

This guide will show you how to get a production-ready reverse proxy up and running quickly.

Prerequisites:

  • Basic terminal / command line skills
  • caddy in your PATH
  • A running backend process to proxy to

There are two easy ways to get a quick reverse proxy up and running. We'll show you two equivalent ways to do the same thing.

This tutorial assumes you have a backend HTTP service running on 127.0.0.1:9000.

Command line

In your terminal, run this command:

caddy reverse-proxy --to 127.0.0.1:9000

Caddy's default address is :2015, so make a request to localhost:2015 to see it working!

It's easy to change the proxy's address:

caddy reverse-proxy --from :2016 --to 127.0.0.1:9000

Now you can access the proxy at localhost:2016.

Caddyfile

In the current working directory, create a file called Caddyfile with these contents:

localhost

reverse_proxy 127.0.0.1:9000

Then, from the same directory, run:

caddy run

You can then make a request to localhost:2015 to see it working!

It's easy to change the proxy's address:

:2016

reverse_proxy 127.0.0.1:9000

Make sure to reload Caddy (or stop and start it again) when you change the Caddyfile.

Now you can access the proxy at localhost:2016.

There is a lot more you can do with the reverse_proxy directive.