Wildcard subdomain information to the pod via Traefik ingress routes

11/24/2021

I am trying to set up a K8s deployment where Traefik v2 proxy ingress's controller.

We have different subdomains that are growing over time.

  • apple.domain.io
  • pears.domain.io
  • strawberries.domain.io
  • ...

Each domain access with a reverse proxy to different servers.

In the single server approach it was managed by a nginx, and it manages the information like this:

    server {
    	server_name ~(?<fruit>\w+).PUBLIC_DOMAIN;
    	listen 443 ssl;
    
    	ssl_certificate     /certs/star.PUBLIC_DOMAIN.crt;
    	ssl_certificate_key /certs/star.PUBLIC_DOMAIN.key;
    
    	auth_request /api/auth/;
    
    	client_max_body_size 100M;
    
    	proxy_buffering off;
    	proxy_request_buffering off;
    
    	location / {
    		proxy_pass http://example.com/$fruit;
    		proxy_redirect http://localhost/ /;
    
    		proxy_http_version 1.1;
    		proxy_set_header Upgrade $http_upgrade;
    		proxy_set_header Connection $connection_upgrade;
    
    		allow all;
    	}
    }

In our k8s approach, we created a pod with an Nginx with the "same" configuration, but we are not finding the way to send the subdomain information to it.

I think I am lost in some part of the way. What would be the way to send the subdomain information to the Nginx?

-- Elektroi
kubernetes
nginx
reverse-proxy
traefik
wildcard-subdomain

0 Answers