使用IIS作為Proxy轉向Jenkins

   在Window主機上裝了Jenkins,預設port 8080,而DNS指定的port與防火牆只有開放80,若想讓Jenkins在外部也可以連的話,IIS有相關套件可以將domain name rewrite到指定的url 例:jenkins.kimx.info 轉往 localhost:8080

必要安裝

  • URL Rewrite
  • Application Request Routing
這2個套件可以透過Web Plaform Installer安裝

IIS設定

1.先新增一個空的網站
image

2.到目錄C:\inetpub\wwwroot\Jenkins 新增一個web.config,並將以下的內容貼上。
此為UrlRewrite的設定

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Reverse Proxy to Jenkins" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

image

ps:也可以指向另一台機械 e.g http://kim-msi:8080/
3.將Proxy設定打開

image
打開後,按右鍵
image
打開Proxy
image
作完後,IIS重新啟動後,就可以透過Domain Name 連結
image

後記

關於登入機制,若沒有架設AD,又不想使用Jenkins內建資料庫的話,直接使用IIS 上的Window認證,也是不錯選擇
image


參考來源

這個網誌中的熱門文章

IIS 設定只允許特定IP進入