Traefik v3 - Reverse Proxy to External IP

Hello,

I was used to nginx wher I had the following config:

...
upstream backend_upstream {
  server <BACKEND_IP>:<PORT>;
}
...
server {
  listen 443 ssl http2;
  server_name mydomain.com www.mydomain.com;
  ...
  location /api/ {
    proxy_pass http://backend_upstream/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}

My frontend accesses the backend (in other server / ip) using the same frontend domain with route /api.
Only the frontend server can make calls to backend, and with this nginx config, my API was accessed by mydomain.com/api.

How can I make the same configuration in traefik, using a reverse proxy to another server / ip ?

Check simple Traefik external example, middleware is optional. You need to use a dynamic config file, which is loaded in static config. Traefik will set the forward headers automatically.

1 Like