Skip to content
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

wildcard behind wildcard #1

Open
johnjelinek opened this issue Aug 7, 2015 · 1 comment
Open

wildcard behind wildcard #1

johnjelinek opened this issue Aug 7, 2015 · 1 comment

Comments

@johnjelinek
Copy link

I'm hosting this container behind openshift (kubernetes) and so there's a wildcard DNS entry for containers through HAProxy. How would I set a wildcard CNAME for my DOMAINALIAS (which is set to the the hostname in the wildcard). I hope this makes sense.

@lonelycode
Copy link
Owner

To clarify - HAProxy gives each container a random CNAME entry? like jaunty_horse.domain.com and iggy_falafel.domain.com and you need the host manager to listen on those domains when the container starts?

The DOMAINALIAS setting in the run command basically just sets an environment variable, this ENV variable is then processed by a script (entrypoint.sh) which does a search and replace on the nginx configuration templates stored in the container. It's just a convenient way to do the domain configuration.

You have full control over those files, look at them here

You can see where the DOMAINALIAS replacements are, you could use a -v volume override to override these files with your own, the file you probably want to change would be the portal.conf, as this sets up the API structure as follows:

organisation-slug.domain.com/portal/
organisation-slug.domain.com/api-slug1/
organisation-slug.domain.com/api-slug2/

The thing is, those files make use of subdomains as the main entrypoint and use the organisation ID (or the organisation slug) to properly identify the portal owner, so you would have jaunty-racoon.org-slug.domain.com/api-slug1/ and figgy-ohare.org-slug.domain.com/api-slug1/ pointing at the same API.

To get this to work you might want something like this in the portal.conf server_name field:

# change this
server_name {{.OwnerSlug}}.DOMAINALIAS;

# to this:
server_name DOMAINALIAS.{{.OwnerSlug}}.fixed-internal-domain.com;

That will now prepnd the DOMAINALIAS variable, which I'm hoping you can dynamically set using a script when kubernetes brings up the container.

If you have only one internal organisation, you could completely remove the if conditions around the OrgSlug server_name component and just have:

server_name DOMAINALIAS.fixed-internal-domain.com;

Or, if you pass the entire CNAME into the run command:

server_name DOMAINALIAS;

This is just an idea - lots of assumptions there :-/ but your solution definetely lies in taking control over those templates and m oulding them to your domain requirements.

M.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants