Nginx location equivalent

Hi,

I'm trying to understand the equivalent of location in Traefik. For example I have this and am trying to convert it to traefik:

server {

.......


  location /nz/connect/ {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_pass       http://10.130.171.175:80;
}

  location /nzassets/ {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_pass       http://10.130.171.175:80;
}

  location / {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_pass       http://10.130.171.175:80;
}
...........
}

Anyone can explain or point to a document that explains? Thanks much appreciated!

Hello @bboy8012,

What are you trying to do ?

If your request is to add those headers, Traefik add by default all these headers :

Accept-Encoding
X-Forwarded-For
X-Forwarded-Host
X-Forwarded-Port
X-Forwarded-Proto
X-Forwarded-Server
X-Real-Ip

If you want to add more headers, you can use this middleware : Headers - Traefik

1 Like

Additionally, you can use Path and PathPrefix to create a routing rule based on the URI coming with the request. Then, each of the routers can have a separate configuration as it was mentioned by Tom in the previous post.

Please let us know if you need more clarification in regards to that.

1 Like

Thank you guys, for the info and replies, as I started digging into it more, I'm finding it's not Traefik that I'm having the issue with persay, it's Authenlia, and the redirect after successful authentication. So I am currently debugging Authelia and the redirect to another path after successful authentication.

Happy debugging and let us know what are the final results :wink: Fingers crossed!

1 Like