# Serving Phoenix application - rev proxy?

**URL:** <https://forum.elixirforum.com/t/serving-phoenix-application-rev-proxy/53476>\
**Category:** Questions\
**Tags:** phoenix, deployment\
**Created:** [January 27, 2023, 6:09pm UTC](https://forum.elixirforum.com/t/serving-phoenix-application-rev-proxy/53476 "2023-01-27T18:09:45Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![derpycoder](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/derpycoder/32/31388_2.png) [@derpycoder](https://forum.elixirforum.com/u/derpycoder)\
**Post date:** [January 28, 2023, 1:30pm UTC](https://forum.elixirforum.com/t/serving-phoenix-application-rev-proxy/53476/6 "2023-01-28T13:30:09Z")

</div>

I used [Caddy](https://caddyserver.com) for local development.

Will deploy it someday. It’s super easy.

It automatically fetches and renews Letsencrypt certs for your main domain and subdomains.

Also, it’s 4x faster than Nginx and super simple to use.

```elixir
www.derpycoder.site {
	redir https://derpycoder.site permanent
}

derpycoder.site {
	tls certs/caddy/cert.pem certs/caddy/key.pem // For local development I used Mkcert, remove this in Production
	encode zstd gzip

	reverse_proxy localhost:4000 {
		header_up Host {host}
		header_up Origin {host}
		header_up X-Real-IP {remote}
		header_up X-Forwarded-Host {host}
		header_up X-Forwarded-Server {host}
		header_up X-Forwarded-Port {port}
		header_up X-Forwarded-For {remote}
		header_up X-Forwarded-Proto {scheme}
		header_down Access-Control-Allow-Origin https://derpycoder.site
		header_down Access-Control-Allow-Credentials true
	}
}

docs.derpycoder.site {
	encode zstd gzip

	root * doc
	file_server browse
}

```

I can have basic-auth to protect subdomains, using [Caddy Auth](https://authp.github.io/docs/authenticate/auth-portal), if you have apps that are admin-only.

It’s really useful apart from security as well, for instance, you can do rolling or canary deployment, and Caddy will route traffic to one instance or the other.

* * *

I don’t know how to do the Active-Active load balancing using Keepalived, perhaps others have experience with that.

---

_[View the full topic](https://forum.elixirforum.com/t/serving-phoenix-application-rev-proxy/53476)._
