One Application Using Multiple Domains
lzc-manifest.yml:application.subdomain is the domain name expected by developers, but the LCMD system (after v1.3.6+) will make certain adjustments
- If multiple applications use the same
subdomainfield, the one installed later will have a domain suffix added - For multi-instance type applications, each user of the same application will be assigned an independent domain, so non-administrators will most likely see domains with suffixes added
- Domain prefix concept: The domain
xxxx-subdomainhas the same effect assubdomain, meaning each application automatically has any number of domains. - The final actually assigned
subdomaincan only be obtained through the environment variableLAZYCAT_APP_DOMAIN. - All traffic entering from prefix domains will ignore
TCP/UDP Ingressconfiguration. (Does not affect traffic entering from default application domain)
v1.3.8 supports Domain-based Traffic Forwarding
Since application.routes does not support domain-based forwarding, if you need more detailed routing rule adjustments, you can add a special route rule, - /=http://nginx.$appid.lzcapp. Note that you must use the $service.$appid.lzcapp form here, otherwise nginx cannot receive complete domain information, see reason
For example, the effect of the following configuration is:
- Opening from the application list defaults to
whoami.xx.heiyu.space(assuming the actually assignedsubdomainiswhoami) nginx-whoami.xx.heiyu.spacetraffic will return the default nginx static hello worldany-content-whoami.xx.heiyu.spacehas the same effect as accessingwhoami.xx.heiyu.space
yaml
package: org.snyh.debug.whoami
name: whoami-lazycatmicroserver
application:
subdomain: whoami
routes:
- /=http://nginx.org.snyh.debug.whoami.lzcapp:80
services:
nginx:
image: registry.lazycat.cloud/snyh1010/library/nginx:54809b2f36d0ff38
setup_script: |
cat <<'EOF' > /etc/nginx/conf.d/default.conf
server { # whoami.xxx.heiyu.space and any other domain prefixes forward to traefik/whoami
server_name _;
location / {
proxy_pass http://app1:80;
# Currently the setup_script mechanism still has some issues, environment variables cannot be written directly here. If you have this need, you can
# only use binds to put files in pkg/content and bind them in
}
}
server { # Domains starting with nginx forward to nginx default page, such as nginx3-whoami.xxx.heiyu.space, nginx-whoami.xxx.heiyu.space
server_name ~^nginx.*-.*;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
EOF
app1:
image: registry.lazycat.cloud/snyh1010/traefik/whoami:c899811bc4a1f63a
package: org.snyh.debug.whoami
name: whoami-lazycatmicroserver
application:
subdomain: whoami
routes:
- /=http://nginx.org.snyh.debug.whoami.lzcapp:80
services:
nginx:
image: registry.lazycat.cloud/snyh1010/library/nginx:54809b2f36d0ff38
setup_script: |
cat <<'EOF' > /etc/nginx/conf.d/default.conf
server { # whoami.xxx.heiyu.space and any other domain prefixes forward to traefik/whoami
server_name _;
location / {
proxy_pass http://app1:80;
# Currently the setup_script mechanism still has some issues, environment variables cannot be written directly here. If you have this need, you can
# only use binds to put files in pkg/content and bind them in
}
}
server { # Domains starting with nginx forward to nginx default page, such as nginx3-whoami.xxx.heiyu.space, nginx-whoami.xxx.heiyu.space
server_name ~^nginx.*-.*;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
EOF
app1:
image: registry.lazycat.cloud/snyh1010/traefik/whoami:c899811bc4a1f63a