Closed emcniece closed 6 years ago
All in all an good idea.
About the redirect-target
, i don't know if rancher-gen sorts the services in the same way as they are exposed to the webinterface, if so i would use the normal programing rule, last definded is the one which is used, it would be easier in the template and also i think it wouldn't make sense if i use the same service multiple times that one of them had other labels for domains redirects etc. that sound like a job for docker-compose but startet multiple times. i hope this make sense.
But we shouldn't forget about the hosts - i think we should go the way host > service > container. so if an host with an domain is specified we shouldn't allow an service which has the same domain and so on, or we use the same as above and the last one counts.
Resolved by https://github.com/CausticLab/rgon-proxy/pull/50
Just discovered that since we iterate services (and not domains specifically) it is possible to create duplicate (and conflicting)
upstream
andserver
directives.Consider this:
Each of these services is tagged with
rgon.domain = mysite.com
, but looking at nginx.tmpl#L233 we are iterating services, which will run 3 times for this example: once for the Nginx services, and once for the dummy instance. This creates something like:I think that it may be possible to have multiple services referencing a single domain name. It may also be possible to have multiple stacks (maybe even with multiple services) referencing a domain name.
Should we abstract our domain iterator in such a way that makes it possible to multiple services across multiple stacks be included in a single
upstream
andserver
directive? If a user is tagging a container with a domain name, perhaps it would be best to allow them to do so successfully without producing annginx.conf
that errors immediately.The solution may be simple - take the following block:
The
$services
would be passed directly into theupstream
template, and$redirect_target
would need to either parse all labels in all services or just take the first one it finds (assuming that each service under this domain would be a similar behaviour):This should be sufficient for allowing cross-service and cross-stack domain name upstream association.