IIS Equivalent of “proxy_set_header X-Forwarded-Proto https;”

时光怂恿深爱的人放手 提交于 2019-12-22 11:16:14

问题


What is the IIS equivalent of this configuration in NGINX?

proxy_set_header X-Forwarded-Proto https;

I am running JetBrains YouTrack on Windows server, using IIS as a terminating SSL proxy, and get this error when trying to log in:

HTTP ERROR 405

Problem accessing /hub/auth/login. Reason:

    HTTP method POST is not supported by this URL
Powered by Jetty://

My web.config looks like this:

<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>

I am trying to follow the solution from this source: https://confluence.jetbrains.com/display/YTD65/Linux.+JAR+in+Nginx+Web+Server, but for IIS


回答1:


Resolved after finding 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>


来源:https://stackoverflow.com/questions/34680786/iis-equivalent-of-proxy-set-header-x-forwarded-proto-https

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