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 Benchmarks - Træfik | Traefik | v1.4
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:
-
listen 80; listen [::]:80
= EntryPoints, Configuration Examples - Traefik
Listen at Port 80 (IPv4) ; Listen at Port 80 (IPv6)
see Module ngx_http_core_module | nginx documentation for the full syntax -
server_name subdomain.example.com
= Routers, Rule - Traefik, may need to be extend by Routers, Service - Traefik
The URL for which the client (user) is heading. NGINX defines that a server name what is theService
in Traefik slang.additional infos
Server names | nginx documentation:
Server names are defined using the server_name directive and determine which server block is used for a given request. See also “How nginx processes a request”. They may be defined using exact names, wildcard names, or regular expressions:
-
proxy_http_version 1.1
-
proxy_set_header
= Headers, Adding Headers to the Request - Traefik
Change what the clients (user) sends (says) want to say to the service (app).additional infos
Module ngx_http_proxy_module | nginx documentation
Allows redefining or appending fields to the request header passed to the proxied server. The
value
can contain text, variables, and their combinations. These directives are inherited from the previous level if and only if there are noproxy_set_header
directives defined on the current level. By default, only two fields are redefined:proxy_set_header Host $proxy_host; proxy_set_header Connection close;
-
proxy_set_header Host $http_host
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
X-Forwarded-For - Wikipedia -
proxy_set_header X-Forwarded-Proto $scheme
-
proxy_set_header X-Real-IP $remote_addr
Module ngx_http_realip_module | nginx documentation:
X-Real-IP header confusion in nginx - Stack Overflow
X-Real-IP with docker swarm and TCP LB | nerd.vision
X-Real-IP should probably be preferred over X-Forwarded-For in _extraClientIP directive? · Issue #1670 · akka/akka-http · GitHub
X-Forwarded-For, Forwarded, X-Real-IP and Nginx - OneFeed
-
-
proxy_pass
= Routers, Service - Traefik but in most cased handled by Routers, Rule - Traefik, e.g. see Docker, Service Definition - Traefik
The location of the target service (app) where the client wants to speak to.additional infos
Module ngx_http_proxy_module | nginx documentation:
Sets the protocol and address of a proxied server and an optional URI to which a location should be mapped. As a protocol, “
http
” or “https
” can be specified. The address can be specified as a domain name or IP address, and an optional port:proxy_pass http://localhost:8000/uri/;
or as a UNIX-domain socket path specified after the word “
unix
” and enclosed in colons:proxy_pass http://unix:/tmp/backend.socket:/uri/;