ProxyPassReverseCookieDomain equivalent for IIS

倾然丶 夕夏残阳落幕 提交于 2019-12-13 04:19:01

问题


I use IIS and URL rewrite as a reverseProxy. My actual webapplication is hosted on a server which is not directly accessible to the internet.

In the rewrite rules I replace the host name of the reverse Proxy with the local IP address. This works fine.

However, the application I use provides downloads. Once the client makes a download request a server side process redirects to the actual download file.

This is where I have issues. It seems like the session cookie (JSESSIONID) is not correctly shared between reverse proxy and local server. Instead of being redirected to the download file, I get a 401 "not authorized" message from the local server.

I found a similar question here. How to properly set JSESSIONID cookie path behind reverse proxy The user was using Apache as a reverse proxy and was using ProxyPassReverseCookieDomain to rewrite the cookie domain name.

Is there a similar setting in IIS? I tried the following outbounding rule but this doesn't work.

<preCondition name="contains-domain-set-cookie-header">
  <add input="{RESPONSE_Set_Cookie}" pattern=".*?domain=MYDOMAIN*?" />
</preCondition>
<rule name="rewrite cookie domain" preCondition="contains-domain-cookie-header">
  <match serverVariable="RESPONSE_Set_Cookie" pattern="^(.*?domain=)MYDOMAIN(.*?)$" negate="false" />
  <action type="Rewrite" value="{R:1}MYLOCALIP{R:2}" /> 
</rule>

Are there other ways to handle this?

Thanks,

Thomas


回答1:


Found the answer here and here

To preserve the Host Header run this from command line to update Machine/webroot/apphost config

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost


来源:https://stackoverflow.com/questions/46534125/proxypassreversecookiedomain-equivalent-for-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!