Prev Next

Web / Traefik Interview questions

How do you write and load a custom Traefik plugin using Yaegi?

Traefik plugins are written in Go but run through Yaegi, an embedded Go interpreter, rather than being compiled into the Traefik binary, which lets plugins load and update without rebuilding or restarting Traefik itself.

A plugin implements a standard interface: a constructor function and a ServeHTTP method that receives the request, can inspect or modify it, and then calls the next handler in the chain, following the same middleware pattern Traefik uses internally.

func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error) {
    return &MyPlugin{next: next, name: name}, nil
}

func (p *MyPlugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
    req.Header.Set("X-Custom", "value")
    p.next.ServeHTTP(rw, req)
}

Plugins are declared in the static configuration under experimental.plugins, pointing at a module name and version pulled from the Plugin Catalog (or a local plugin during development), and are then used just like any built-in middleware by referencing the plugin's type in a middleware definition.

Because Yaegi interprets rather than compiles the plugin code, it trades some runtime performance for the safety of not needing arbitrary compiled code baked into the core Traefik binary, which matters for a proxy sitting at the edge of untrusted traffic.

Traefik plugins run through which mechanism, instead of being compiled into the binary?
What does a plugin's ServeHTTP method ultimately do after processing?

More Related questions...

What is Traefik? What are the main features of Traefik? What is the purpose of an entrypoint in Traefik? What are routers in Traefik? What are services in Traefik? What are middlewares in Traefik? What are providers in Traefik? How do you enable the Traefik dashboard? Define an IngressRoute in Traefik? What is the Traefik file provider? How do you configure Traefik using Docker labels? What is the purpose of Let's Encrypt integration in Traefik? List the supported configuration providers in Traefik? What is a certificate resolver in Traefik? What is a middleware chain in Traefik and why order it carefully? Why is dynamic configuration preferred over static configuration for routing rules? What is the difference between Path and PathPrefix routing rules? What is the difference between Host and HostRegexp rules? How does Traefik handle load balancing across multiple service instances? Why would you use sticky sessions in Traefik? How do health checks work in Traefik? What is the difference between Traefik's Ingress support and the IngressRoute CRD? How does the ForwardAuth middleware work? Why is middleware chaining order important in Traefik? How do you configure CORS headers with Traefik middleware? What is the difference between HTTP-01 and DNS-01 challenge types in Let's Encrypt? How does Traefik implement weighted round robin for canary deployments? When should you use the RateLimit middleware? How does the Retry middleware behave with failing backends? What is the difference between Traefik and Nginx as reverse proxies? How do you configure basic authentication in Traefik? Why does Traefik require the exposedByDefault setting to be handled carefully in Docker? How does SNI-based routing work in Traefik? What is the difference between a router's priority and its rule matching? How do you redirect HTTP traffic to HTTPS using Traefik middleware? Explain the execution flow of a request through Traefik's router, middleware, and service chain? How does Traefik's hot-reload mechanism detect and apply dynamic configuration changes? Explain how mutual TLS (mTLS) is configured between Traefik and backend services? How do you write and load a custom Traefik plugin using Yaegi? What is the difference between TCP routers and HTTP routers in Traefik? How do you troubleshoot a 404 'page not found' response in Traefik when the backend is healthy? Explain how Traefik integrates with OpenTelemetry for distributed tracing? How can you optimize Traefik for high-availability deployments? Explain the internal working of ServersTransport in Traefik? What is the difference between Traefik's Gateway API support and the traditional IngressRoute CRD? Explain the lifecycle of a Let's Encrypt certificate managed by Traefik? How does Traefik expose metrics for Prometheus scraping? Explain how HTTP/3 support works in Traefik and its requirements? How do you debug middleware ordering issues causing unexpected routing behavior? Explain the internal working of Traefik's provider aggregation across multiple sources?
Show more question and Answers...


Comments & Discussions