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:\Windows\system32\inetsrv\config\applicationHost.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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM