"proxy_set_header X-Forwarded-Proto https;" 的 IIS 等价物
IIS Equivalent of "proxy_set_header X-Forwarded-Proto https;"
NGINX 中此配置的 IIS 等效项是什么?
proxy_set_header X-Forwarded-Proto https;
我在 Windows 服务器上 运行 JetBrains YouTrack,使用 IIS 作为终止 SSL 代理,尝试登录时出现此错误:
HTTP ERROR 405
Problem accessing /hub/auth/login. Reason:
HTTP method POST is not supported by this URL
Powered by Jetty://
我的 web.config 看起来像这样:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Reverse Proxy" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<!-- Redirect all requests to non-HTTPS site. -->
<action type="Rewrite" url="http://my.youtrack.site/{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
<handlers>
<clear />
<!-- No other handlers required. Must clear them otherwise ASP.NET might try to intercept *.svc paths etc. -->
<add name="Rewrite" path="*" verb="*" modules="RewriteModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
我正在尝试从这个来源中寻找解决方案:https://confluence.jetbrains.com/display/YTD65/Linux.+JAR+in+Nginx+Web+Server,但对于 IIS
找到后解决https://confluence.jetbrains.com/display/YTD65/Configuring+Proxy#ConfiguringProxy-IISreverseproxy
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Reverse Proxy" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<!-- Redirect all requests to non-HTTPS site. -->
<action type="Rewrite" url="http://my.youtrack.site/{R:1}" logRewrittenUrl="true" />
<serverVariables>
<set name="HTTP_X_FORWARDED_HOST" value="{HTTP_HOST}" />
<set name="HTTP_X_FORWARDED_SCHEMA" value="https" />
<set name="HTTP_X_FORWARDED_PROTO" value="https" />
</serverVariables>
</rule>
</rules>
<allowedServerVariables>
<add name="HTTP_X_FORWARDED_HOST" />
<add name="HTTP_X_FORWARDED_SCHEMA" />
<add name="HTTP_X_FORWARDED_PROTO" />
</allowedServerVariables>
</rewrite>
<handlers>
<clear />
<!-- No other handlers required. Must clear them otherwise ASP.NET might try to intercept *.svc paths etc. -->
<add name="Rewrite" path="*" verb="*" modules="RewriteModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
我能够使用以下脚本将 X-Forwarded-Proto header 添加到应用程序请求路由转发的所有请求中:
Set-WebConfiguration -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/allowedServerVariables" -Value (@{name="HTTP_X_FORWARDED_PROTO"})
Set-WebConfiguration -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/globalRules" -value @{name='ForwardedHttps'}
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/globalRules/rule[@name='ForwardedHttps']/serverVariables" -name "." -value @{name='HTTP_X_FORWARDED_PROTO';value='https'}
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/globalRules/rule[@name='ForwardedHttps']/conditions" -name "." -value @{input='{HTTPS}';pattern='On'}
为了使代码处理 HTTP/HTTPS 正确重定向,可能还需要设置以下配置设置:
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/proxy" -name "preserveHostHeader" -value "True"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/proxy" -name "reverseRewriteHostInResponseHeaders" -value "False"
NGINX 中此配置的 IIS 等效项是什么?
proxy_set_header X-Forwarded-Proto https;
我在 Windows 服务器上 运行 JetBrains YouTrack,使用 IIS 作为终止 SSL 代理,尝试登录时出现此错误:
HTTP ERROR 405
Problem accessing /hub/auth/login. Reason:
HTTP method POST is not supported by this URL
Powered by Jetty://
我的 web.config 看起来像这样:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Reverse Proxy" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<!-- Redirect all requests to non-HTTPS site. -->
<action type="Rewrite" url="http://my.youtrack.site/{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
<handlers>
<clear />
<!-- No other handlers required. Must clear them otherwise ASP.NET might try to intercept *.svc paths etc. -->
<add name="Rewrite" path="*" verb="*" modules="RewriteModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
我正在尝试从这个来源中寻找解决方案:https://confluence.jetbrains.com/display/YTD65/Linux.+JAR+in+Nginx+Web+Server,但对于 IIS
找到后解决https://confluence.jetbrains.com/display/YTD65/Configuring+Proxy#ConfiguringProxy-IISreverseproxy
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Reverse Proxy" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<!-- Redirect all requests to non-HTTPS site. -->
<action type="Rewrite" url="http://my.youtrack.site/{R:1}" logRewrittenUrl="true" />
<serverVariables>
<set name="HTTP_X_FORWARDED_HOST" value="{HTTP_HOST}" />
<set name="HTTP_X_FORWARDED_SCHEMA" value="https" />
<set name="HTTP_X_FORWARDED_PROTO" value="https" />
</serverVariables>
</rule>
</rules>
<allowedServerVariables>
<add name="HTTP_X_FORWARDED_HOST" />
<add name="HTTP_X_FORWARDED_SCHEMA" />
<add name="HTTP_X_FORWARDED_PROTO" />
</allowedServerVariables>
</rewrite>
<handlers>
<clear />
<!-- No other handlers required. Must clear them otherwise ASP.NET might try to intercept *.svc paths etc. -->
<add name="Rewrite" path="*" verb="*" modules="RewriteModule" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
我能够使用以下脚本将 X-Forwarded-Proto header 添加到应用程序请求路由转发的所有请求中:
Set-WebConfiguration -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/allowedServerVariables" -Value (@{name="HTTP_X_FORWARDED_PROTO"})
Set-WebConfiguration -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/globalRules" -value @{name='ForwardedHttps'}
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/globalRules/rule[@name='ForwardedHttps']/serverVariables" -name "." -value @{name='HTTP_X_FORWARDED_PROTO';value='https'}
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/rewrite/globalRules/rule[@name='ForwardedHttps']/conditions" -name "." -value @{input='{HTTPS}';pattern='On'}
为了使代码处理 HTTP/HTTPS 正确重定向,可能还需要设置以下配置设置:
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/proxy" -name "preserveHostHeader" -value "True"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/proxy" -name "reverseRewriteHostInResponseHeaders" -value "False"