iT邦幫忙

2

[IIS][GitLab] Reverse Proxy 後的小問題

同步發表 Blog:[IIS][GitLab] Reverse Proxy 後的小問題

既上次 [IIS][GitLab] 利用 IIS Reverse Proxy 將 GitLab 加上 Https 將 gitlab 擺到 iis 後面之後,遇到部分功能無法正常使用的問題

  1. 無法瀏覽 .cs.config 等檔案
  2. 無法使用 WebIDE
  3. 無法使用 檔案庫 -> 比較 功能

問題緣由

  • 無法瀏覽 .cs.config 等檔案
  • 無法使用 檔案庫 -> 比較 功能

會產生上面兩點的原因是 IIS 對靜態檔案有預設的保護機制,不會將不認識的副檔名暴露給外部連線下載,其中 .config 更是 ASP.NET 設定檔的副檔名,但這站台只是當作中繼站做轉發的動作而已,所以我判斷可以關閉所有安全機制。

解決方法

  1. 開啟 web.config
  2. 找到 configuration -> system.webServer -> staticContent 結點 (若無則新增)
  3. 新增下列設定
<mimeMap fileExtension=".*" mimeType="application/octet-stream" />
<mimeMap fileExtension="." mimeType="application/octet-stream" />
  1. 找到 configuration -> system.webServer -> security 結點 (若無則新增)
  2. 新增下列設定
<requestFiltering>
	<hiddenSegments>
		<clear />
	</hiddenSegments>
	<denyUrlSequences>
		<clear />
	</denyUrlSequences>
	<fileExtensions allowUnlisted="true">
		<clear />
	</fileExtensions>
</requestFiltering>

問題緣由

  • 無法使用 WebIDE

這個問題是因為 IIS 將網址重複 UrlEncode 兩次,讓藏在後面的 gitlab 無法正確辨識網址。

解決方法

  1. 開啟 web.config
  2. 找到 configuration -> system.webServer -> rewrite -> rules 結點
  3. 新增 useOriginalURLEncoding 屬性如下
<rules useOriginalURLEncoding="false">
	....
</rules>
  1. 找到 gitlab 反向代理 rule -> action 結點並修改 url 屬性如下
<action type="Rewrite" url="http://192.168.1.100{UNENCODED_URL}" />

參考資料:

  1. How to disable Request Filtering for a specific website on IIS 7.5?
  2. IIS10 URL Rewrite 2.1 double encoding issue
  3. Running Jenkins behind IIS

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言