How to add X-Real-Port header to forwarded request?

Hello!

I am using traefik 2.4 with host mode ports.
X-Real-Ip header is properly sent to upstream, but there is no X-Real-Port.
I've been looking into documentation and there is nothing mentioned about such header or variable responsible for remote_port (that's how it is handled by nginx internaly).
Is there any possible way to obtain remote client port number and include it in header sent to target service like it is done with remote client IP in X-Real-Ip?

Read the middlewares headers section in the official documentation

1 Like

Hi diegodevops.
Thank you for your answer. I've already went through documentation quite a few times, including middleware and headers section. Unfortunately there is no answer to my question or it escaped my attention.

I would be delighted if you point me something more particular as an answer than RTFM.

Till now I've found that there is plugin which might be a good point to start: Plugin but still if there is a better way, and according to your pointing in documentation there should be, I would like to stick with vanilla solution.

Best regards

That plugin looks interesting

Sorry not being more useful, I know the middleware section is quite tricky, special for headers.

I'm glad I haven't needed too many headers in my deployments. Only X-Forwarded-Proto for https

Best