Real life usage of the X-Forwarded-Host header?

前端 未结 7 505
予麋鹿
予麋鹿 2021-01-30 05:09

I\'ve found some interesting reading on the X-Forwarded-* headers, including the Reverse Proxy Request Headers section in the Apache documentation, as well as the

7条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 05:33

    This is the scenario I worked on today: Users access certain application server using "https://neaturl.company.com" URL which is pointing to Reverse Proxy. Proxy then terminates SSL and redirects users' requests to the actual application server which has URL of "http://192.168.1.1:5555". The problem is - when application server needed to redirect user to other page on the same server using absolute path, it was using latter URL and users don't have access to this. Using X-Forwarded-Host (+ X-Forwarded-Proto and X-Forwarded-Port) allowed our proxy to tell application server which URL user used originally and thus server started to generate correct absolute path in its responses.

    In this case there was no option to stop application server to generate absolute URLs nor configure it for "public url" manually.

提交回复
热议问题