Skip to content

Commit 5c3be56

Browse files
zeripathmrsdizzie
andauthored
Add IIS Reverse Proxy documentation (#10881)
* Add IIS Reverse Proxy documentation @mahdiit in #10748 described how to set up IIS as a reverse proxy. This PR adds these to our documentation. Close #10748 Signed-off-by: Andrew Thornton <[email protected]> * Update docs/content/doc/usage/reverse-proxies.en-us.md Co-Authored-By: mrsdizzie <[email protected]> Co-authored-by: mrsdizzie <[email protected]>
1 parent 29ed07e commit 5c3be56

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

docs/content/doc/usage/reverse-proxies.en-us.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,59 @@ git.example.com {
174174
```
175175

176176
Then set `[server] ROOT_URL = http://git.example.com/git/` in your configuration.
177+
178+
## Using IIS as a reverse proxy
179+
180+
If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite as reverse proxy.
181+
182+
1. Setup an empty website in IIS, named let's say, `Gitea Proxy`.
183+
2. Follow the first two steps in [Microsoft's Technical Community Guide to Setup IIS with URL Rewrite](https://techcommunity.microsoft.com/t5/iis-support-blog/setup-iis-with-url-rewrite-as-a-reverse-proxy-for-real-world/ba-p/846222#M343). That is:
184+
- Install Application Request Routing (ARR for short) either by using the Microsoft Web Platform Installer 5.1 (WebPI) or downloading the extension from [IIS.net]( https://www.iis.net/downloads/microsoft/application-request-routing)
185+
- Once the module is installed in IIS, you will see a new Icon in the IIS Administration Console called URL Rewrite.
186+
- Open the IIS Manager Console and click on the `Gitea Proxy` Website from the tree view on the left. Select and double click the URL Rewrite Icon from the middle pane to load the URL Rewrite interface.
187+
- Choose the `Add Rule` action from the right pane of the management console and select the `Reverse Proxy Rule` from the `Inbound and Outbound Rules` category.
188+
- In the Inbound Rules section, set the server name to be the host that Gitea is running on with its port. e.g. if you are running Gitea on the localhost with port 3000, the following should work: `127.0.0.1:3000`
189+
- Enable SSL Offloading
190+
- In the Outbound Rules, ensure `Rewrite the domain names of the links in HTTP response` is set and set the `From:` field as above and the `To:` to your external hostname, say: `git.example.com`
191+
- Now edit the `web.config` for your website to match the following: (changing `127.0.0.1:3000` and `git.example.com` as appropriate)
192+
193+
```xml
194+
<?xml version="1.0" encoding="UTF-8"?>
195+
<configuration>
196+
<system.webServer>
197+
<rewrite>
198+
<rules>
199+
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
200+
<match url="(.*)" />
201+
<action type="Rewrite" url="http://127.0.0.1:3000/{R:1}" />
202+
<serverVariables>
203+
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="HTTP_ACCEPT_ENCODING" />
204+
<set name="HTTP_ACCEPT_ENCODING" value="" />
205+
</serverVariables>
206+
</rule>
207+
</rules>
208+
<outboundRules>
209+
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
210+
<!-- set the pattern correctly here - if you only want to accept http or https -->
211+
<!-- change the pattern and the action value as appropriate -->
212+
<match filterByTags="A, Form, Img" pattern="^http(s)?://127.0.0.1:3000/(.*)" />
213+
<action type="Rewrite" value="http{R:1}://git.example.com/{R:2}" />
214+
</rule>
215+
<rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
216+
<match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
217+
<action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
218+
</rule>
219+
<preConditions>
220+
<preCondition name="ResponseIsHtml1">
221+
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
222+
</preCondition>
223+
<preCondition name="NeedsRestoringAcceptEncoding">
224+
<add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />
225+
</preCondition>
226+
</preConditions>
227+
</outboundRules>
228+
</rewrite>
229+
<urlCompression doDynamicCompression="true" />
230+
</system.webServer>
231+
</configuration>
232+
```

0 commit comments

Comments
 (0)