-
Notifications
You must be signed in to change notification settings - Fork 875
Subdomain options for multi-tenanted apps #4288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I may be misunderstanding, but would something like this work in the template? # inside a template main.tf
resource "coder_app" "tenant1" {
url = "http://localhost:8000"
relative_path = false # host the app on a subdomain
}
resource "coder_app" "tenant2" {
url = "http://localhost:8001"
relative_path = false # host the app on a subdomain
}
# the tenant URLs could be shared with the workspace as environment variables
resource "coder_agent" "agentname" {
env {
name = "TENANT1_URL"
value = `https://tenant1--agentname--${data.coder_workspace.me.name}-${data.coder_workspace.me.username}.wildcard-example-domain.com`
}
env {
name = "TENANT2_URL"
value = `https://tenant2--agentname--${data.coder_workspace.me.name}-${data.coder_workspace.me.username}.wildcard-example-domain.com`
}
} The subdomains are namespaced to include the workspace, agent name, and username to avoid conflicts, but the URL is predictable and can be dynamically represented in Terraform. This is in progress in #4263 Let me know if your use case is different though! I wasn't sure if you were looking for unique domains to access Coder or if your NGINX config is "global" outside each workspace, where you may need to specify unique routes. |
Technically Ben's solution already works in the current version of Coder, however any buttons that link to the apps in the dashboard will incorrectly link to the path based app URLs rather than the subdomains you intended to use. That's fixed by #4263 |
@bpmct if i am able to access I've tried the above code on 0.9.7 as per @deansheather message above but I am unable to access the services? |
I think there's a mistake in the URL Ben posted, there should be double hyphens between each thing in the subdomain. So add an extra The Host is preserved from the browser and passed all the way through I believe. If this is not the behavior you're seeing then we definitely need to resolve that. |
Okay, just to throw a spanner in the works, our app uses the hostname header to determine which tenant the client is querying. So is it possible to point both the tenant1 and tenant2 domains to the same service on the same port? |
@bartonip I don't believe there's any limitation on having two apps point to the same service/port inside the workspace |
@deansheather I've just tried the above again and get a big ol' 404 when I try to access those subdomains. I am presuming that the environment variables are just the name of the coder_app uppercased with _URL appended to the name? |
You can check the environment variables in your workspace by running the |
This issue is becoming stale. In order to keep the tracker readable and actionable, I'm going close to this issue in 7 days if there isn't more activity. |
@bartonip were you able to get this working? |
@kylecarbs yep this is all working now :) |
Now that coder supports wildcard domains, it would be awesome if we could add the ability to pre-define subdomains in the terraform config to particular ports/addresses.
The use case that we have is that we are developing a multi-tenanted app where each tenant has their own unique subdomain a-la https://tenant1.ourapp.com, https://tenant2.ourapp.com.
Right now, we have a real sketchy netcat listener that gets curl'd and then updates nginx config when new workspaces get spun up. It would be great if we could specify a default subdomain where the coder_agent could be accessed at and be able to define other subdomains that would point to this agent.
I think this would be advantageous to all companies who are developing apps that run on multiple subdomains.
Please let me know what you think.
The text was updated successfully, but these errors were encountered: