Back

Unable to use domain root to host function

  • 1
  • Self Hosted
  • Functions
  • General
  • REST API
LukeHagar
12 Feb, 2024, 20:12

I can see that the root _APP_DOMAIN_FUNCTIONS is blocked from being used for functions on the below file line https://github.com/appwrite/appwrite/blob/c076dfe6f14ddacc4f658fdff85fbdbe31e05636/app/controllers/general.php#L63

For my current implementation, that means that the domain root cannot be used? I was originally interested in using an Appwrite function to host a site at the root, as well as sites on subdomains, but currently that seems impossible.

TL;DR
Issue: Developer is unable to use domain root to host function in Appwrite. Solution: It is not possible to use the domain root for hosting functions in Appwrite. Instead, it is suggested to use a dedicated domain for the Appwrite instance, such as "appwrite.mycompany.com". For individual projects or sites, custom function domains can be created with specific domains. Adjustments may be required in the proxy implementation for proper functionality.
LukeHagar
12 Feb, 2024, 20:18

I guess this is mostly just a request for confirmation 🙂

Steven
12 Feb, 2024, 20:19

I would suggest using a dedicated domain for your appwrite instance like appwrite.mycompany.com because your appwrite instance can have multiple projects. For 1 of your sites (which I'm assuming is 1 function in one of your projects), you could create a custom function domain with whatever domain you want (myapp.com)

LukeHagar
12 Feb, 2024, 20:22

so that is what I am doing, for appwrite itself, but with the goal of hosting sites on *.mycompany.com I had set the _APP_DOMAIN_FUNCTIONS env var to mycompany.com

This is largely due to my current implementation with Cloudflare proxy, and a nginx reverse proxy handling LetsEncrypt certificates.

I suspect that I would need to adjust my proxy implementation a bit for this to work properly

Steven
12 Feb, 2024, 20:25

with the _APP_DOMAIN_FUNCTIONS, appwrite generates a custom unique subdomain for each function like:

TypeScript
asjidojriweoj.domain.com

so it doesn't make sense to use that for a website URL/domain.

LukeHagar
12 Feb, 2024, 20:26

I was manually assigning the subdomains I wanted to specific functions Like this one right here: https://test.plygrnd.org

LukeHagar
12 Feb, 2024, 20:26

I'm reading through your medium nginx post right now

Steven
12 Feb, 2024, 20:27

maybe you can do:

TypeScript
_APP_DOMAIN=appwrite.mycompany.com
_APP_DOMAIN_FUNCTIONS=functions.appwrite.mycompany.com

And then if you want a site at test.mycompany.com, create a custom function domain for that in the function

LukeHagar
12 Feb, 2024, 20:28

Cloudflare wont do this with the free plan functions.appwrite.mycompany.com And from what I have seen, if I dont set _APP_DOMAIN_FUNCTIONS to the root domain, then the domain verification pops up with the CNAME prompt, which never works

LukeHagar
12 Feb, 2024, 20:29

with _APP_DOMAIN_FUNCTIONS as the domain root, the domains are validated automatically it seems

Steven
12 Feb, 2024, 20:29

in nginx you'd have multiple domains for the same proxy host:

  • appwrite.mycompany.com
  • *.functions.appwrite.mycompany.com
  • test.mycompany.com
LukeHagar
12 Feb, 2024, 20:29

I was just doing *.mycompany.com with a cloudflare DNS challenge

Steven
12 Feb, 2024, 20:31

if that works on the cloudflare side, sure.

on the nginx side...i think *.mycompany.com only goes 1 level so you'd need another entry for *.functions.appwrite.mycompany.com. maybe, im not sure

LukeHagar
12 Feb, 2024, 20:32

I'll give it a shot, thank you!

LukeHagar
12 Feb, 2024, 20:45
LukeHagar
12 Feb, 2024, 20:47

it just refuses to verify

LukeHagar
12 Feb, 2024, 20:47

even though if I navigate to plygrnd.org I get the appwrite login page

LukeHagar
12 Feb, 2024, 20:48

WAIT! even better, verification fails, but the function is working!

LukeHagar
12 Feb, 2024, 20:48

thats a riot

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more
Copyright © 2024 Appwrite