SVN 通过IIS设置反向代理访问

原因

一个字,穷,没办法,只有一台机器 要当测试服务器还要做源码管理。

解决办法

通过IIS配置反向代理访问SVN,给SVN访问的HTTPS绑定上域名,就可以正常访问了。

1、修改SVN配置

把SVN修改为 HTTP访问,端口改掉,随便写一个未被使用的就行 ,本例 90,同时设置绑定的IP地址为:127.0.0.1。设置完这一步以后其他机器就布恩那个访问了。

2、在IIS上安装 URLRewrite和反向代理插件,下载地址

32位:http://download.microsoft.com/download/4/9/C/49CD28DB-4AA6-4A51-9437-AA001221F606/rewrite_x86_zh-CN.msi

64位:http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi

反向代理ARR: http://www.iis.net/downloads/microsoft/application-request-routing

3、打开IIS管理器,新建网站,绑定设置同时绑定http和https,设置证书,绑定域名:svn.xxx.com。

4、配置两条规则:一是把http访问重定向到https,二是设置反向代理,把访问转发到http://localhost:90,注意http访问重定向的规则放在第一位。

<rewrite>
      <rules>
     <!--HTTP重定向到HTTPS--> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule>
    <!--设置反向代理-->
    <rule name="phpweb">
       <match url="^(.*)" />
       <conditions>
           <add input="{HTTP_HOST}" pattern="^svn.xxx.com$" />
       </conditions>
       <action type="Rewrite" url="http://localhost:90/{R:1}" />
    </rule>
      </rules>
    </rewrite>

5、打开网站,修改web.config,添加节点,否则无法提交:

        <security>
            <requestFiltering>
                <fileExtensions>
                    <clear/>
                </fileExtensions>
            </requestFiltering>
        </security>    

6、现在基本上可以了,不过还有个小问题,web.config和bin目录无法提交,在本网站中,打开请求筛选,移除这两项,配置如下:

7、最后多站点配置IIS的https

C:Windowssystem32inetsrvconfigapplicationHost.config

编辑上述路径的配置文件,把每个站点对应的

<binding protocol="https" bindingInformation="*:443" />

改成

<binding protocol="https" bindingInformation="*:443:svn.xxx.com" />

打完收工,全部的配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="HTTP to HTTPS redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
                </rule>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="http://localhost:90/{R:1}" />
                </rule>

            </rules>
        </rewrite>
        <security>
            <requestFiltering>
                <fileExtensions>
                    <clear />
                </fileExtensions>
                <hiddenSegments>
                    <remove segment="App_code" />
                    <remove segment="App_Data" />
                    <remove segment="bin" />
                    <remove segment="web.config" />
                </hiddenSegments>
            </requestFiltering>
        </security>


    </system.webServer>
</configuration>
原文地址:https://www.cnblogs.com/shya/p/7491965.html