How to use multiple domains in a load-balanced environment #8432
Replies: 2 comments 15 replies
-
This shouldn't necessarily matter in Directus itself. That public URL is only used for things like password-reset emails, and other user-facing names. That being said, it doesn't affect the /server/health endpoint at all (Directus itself runs fine regardless of what value you use for PUBLIC_URL). I'm a little confused as to why that would affect the health check at all. How are you health checking currently? |
Beta Was this translation helpful? Give feedback.
-
This was solved somewhere between RC.76 and RC.96 and is no longer a concern. |
Beta Was this translation helpful? Give feedback.
-
When used in a load balanced situation with two nodes and a load balancer, the
public_url
env var breaks the load balance config.server 1 is addressed as
mysite-1.mydomain.org
server 2 is addressed as
mysite-2.mydomain.org
The LB is addressed as
mysite.mydomain.org
.In the Directus config, I've set the
public_url
tomysite.mydomain.org
. This works for the customer facing site and the email invitations. This setup fails when attempting to reach the-1
,-2
sites directly. This is essential as the load balancer health check attempts to reach the downstream servers by their-1
,-2
addresses.Essentially we can run the site without health checks and everything works, or we can enable health checks as is our policy and the site breaks. The load balancer isn't able to get a response from the health check endpoints, and therefore has no active downstream servers to route to.
Lastly, I set the
public_url
variable to/
and everything worked as expected. The load balancer health checks worked, and the site was reachable at all three addresses. I thought this was the solution, until I tried to invite a member of my team to the site and the links in the email were all just relative links prefixed with/
I would suggest separating thi
public_url
variable intopublic_url
andhost_url
, or something along those lines to allow the use of/
as the site host and still havemysite.mydomain.org
in the email prefix and other areas where that would be used.To Reproduce
Deploy a site to two or more servers, with a loadbalancer. Assign the servers addresses, and assign the loadbalancer an address. Set the
public_url
env var to the value of the load balancer address. Ensure health checks are off. The site should work as expected, but the two direct addresses will not work.Set the
public_url
value to/
, and the site should be working as expected. Invite someone to the site, and check the email links. The links will not be complete.Beta Was this translation helpful? Give feedback.
All reactions