NGINX to Traefik translator

Many examples of how to configure the reverse proxy to make the service fully operational server are based on NGINX.

To ease the migration it would help if there are examples of the most common NGINX configuration and how Traefik handles this or can be configured to do the same, respectively.
The only thing I could find is https://docs.traefik.io/v1.4/benchmarks/

I start with the snippet below, contributions are welcome.

server {
	listen 80; listen [::]:80;
	server_name subdomain.example.com;  # <-- change this

	location / {
		proxy_pass http://unix:/...nginx.http.sock:;
		proxy_set_header Host $http_host;
		proxy_http_version 1.1;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_set_header X-Real-IP $remote_addr;
	}
}

1:1 config in Traefik:

## Static configuration
--entryPoints.port80_web.address=:80
## Dynamic configuration
http.routersRouter-NGINX.rule =  "Host(`subdomain.example.com`)"
http.routersRouter-NGINX.entryPoints = port80_web

Explaiend in Detail:

in Mattermost behind Treafik v2 I mentioned

how to define variables like $scheme $remote_addr in traefik v2 header middlewares?

`$scheme`

request scheme, โ€œ `http` โ€ or โ€œ `https` โ€

that would be https://docs.traefik.io/middlewares/redirectscheme/

and

https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/
the closest I can find is https://docs.traefik.io/middlewares/headers/#adding-and-removing-headers

1 Like