|
1
|
# Serving via IIS |
|
2
|
|
|
3
|
## Why Bother? |
|
4
|
|
|
5
|
The first part of the scheme below sets Fossil up as an HTTP server, so |
|
6
|
you might be wondering why you wouldn’t just modify that to make it |
|
7
|
listen on all network interfaces on TCP port 80, so you can avoid the |
|
8
|
need for IIS entirely. For simple use cases, you can indeed do without |
|
9
|
IIS, but there are several use cases where adding it is helpful: |
|
10
|
|
|
11
|
1. Proxying Fossil with IIS lets you [add TLS encryption][tls], which |
|
12
|
[Fossil does not currently speak](../../ssl.wiki) in its server role. |
|
13
|
|
|
14
|
2. The URL rewriting we do below allows Fossil to be part of a larger |
|
15
|
site already being served with IIS. |
|
16
|
|
|
17
|
3. You can have a mixed-mode site, with Fossil acting as a powerful |
|
18
|
dynamic content management service and IIS as a fast static content |
|
19
|
server. The pure-Fossil alternative requires that you check all of |
|
20
|
your static content into Fossil as versioned or unversioned |
|
21
|
artifacts. |
|
22
|
|
|
23
|
This article shows how you can get any combination of those benefits by |
|
24
|
using IIS as a reverse proxy for `fossil server`. |
|
25
|
|
|
26
|
There are other ways to use IIS to serve Fossil, such as [via |
|
27
|
CGI](./cgi.md). |
|
28
|
|
|
29
|
|
|
30
|
## Background Fossil Service Setup |
|
31
|
|
|
32
|
You will need to have the Fossil HTTP server running in the background, |
|
33
|
serving some local repository, bound to localhost on a fixed |
|
34
|
high-numbered TCP port. For the purposes of testing, simply start it by |
|
35
|
hand in your command shell of choice: |
|
36
|
|
|
37
|
fossil serve --port 9000 --localhost repo.fossil |
|
38
|
|
|
39
|
That command assumes you’ve got `fossil.exe` in your `%PATH%` and you’re |
|
40
|
in a directory holding `repo.fossil`. See [the platform-independent |
|
41
|
instructions](../any/none.md) for further details. |
|
42
|
|
|
43
|
For a more robust setup, we recommend that you [install Fossil as a |
|
44
|
Windows service](./service.md), which will allow Fossil to start at |
|
45
|
system boot, before anyone has logged in interactively. |
|
46
|
|
|
47
|
|
|
48
|
## <a id="install"></a>Install IIS |
|
49
|
|
|
50
|
IIS might not be installed in your system yet, so follow the path |
|
51
|
appropriate to your host OS. We’ve tested only the latest Microsoft |
|
52
|
OSes as of the time of this writing, but the basic process should be |
|
53
|
similar on older OSes. |
|
54
|
|
|
55
|
|
|
56
|
### Windows Server 2019 |
|
57
|
|
|
58
|
1. Start “Server Manager” |
|
59
|
2. Tell it you want to “Add roles and features” |
|
60
|
3. Select “Role-based or feature-based installation” |
|
61
|
4. Select your local server |
|
62
|
5. In the Server Roles section, enable “Web Server (IIS)” |
|
63
|
|
|
64
|
### Windows |
|
65
|
|
|
66
|
1. Open Control Panel |
|
67
|
2. Go to “Programs” |
|
68
|
3. Select “Turn Windows features on or off” in the left-side pane |
|
69
|
4. In the “Windows Features” dialog, enable “Internet Information |
|
70
|
Services” |
|
71
|
|
|
72
|
The default set of IIS features there will suffice for this tutorial, |
|
73
|
but you might want to enable additional features. |
|
74
|
|
|
75
|
|
|
76
|
## Setting up the Proxy |
|
77
|
|
|
78
|
The stock IIS setup doesn’t have reverse proxying features, but they’re |
|
79
|
easily added through extensions. You will need to install the |
|
80
|
[Application Request Routing][arr] and [URL Rewrite][ure] extensions. In |
|
81
|
my testing here, URL Rewrite showed up immediately after installing it, |
|
82
|
but I had to reboot the server to get ARR to show up. (Yay Windows.) |
|
83
|
|
|
84
|
You can install these things through the direct links above, or you can |
|
85
|
do it via the Web Platform Installer feature of IIS Manager (a.k.a. |
|
86
|
`INETMGR`). |
|
87
|
|
|
88
|
Set these extensions up in IIS Manager like so: |
|
89
|
|
|
90
|
1. Double-click the “Application Request Routing Cache” icon. |
|
91
|
|
|
92
|
2. Right-click in the window that results, and select “Server Proxy |
|
93
|
Settings...” |
|
94
|
|
|
95
|
3. Check the “Enable Proxy” box in the dialog. Click the “Apply” text |
|
96
|
in the right-side pane. |
|
97
|
|
|
98
|
4. Return to the top server-level configuration area of IIS Manager and |
|
99
|
double-click the “URL Rewrite” icon. Alternately, you might find |
|
100
|
“URL Rewrite” in the right-side pane from within the ARR settings. |
|
101
|
|
|
102
|
5. Right click in the window that results, and click “Add Rule(s)...” |
|
103
|
Tell it you want a “Blank rule” under “Inbound rules”. |
|
104
|
|
|
105
|
6. In the dialog that results, create a new rule called “Fossil repo |
|
106
|
proxy.” Set the “Pattern” to “`^(.*)$`” and “Rewrite URL” set to |
|
107
|
“`http://localhost:9000/{R:1}`”. That tells it to take everything in |
|
108
|
the path part of the URL and send it down to localhost:9000, where |
|
109
|
`fossil server` is listening. |
|
110
|
|
|
111
|
7. Click “Apply” in the right-side pane, then get back to the top level |
|
112
|
configuration for the server, and click “Restart” in that same pane. |
|
113
|
|
|
114
|
At this point, if you go to `http://localhost/` in your browser, you |
|
115
|
should see your Fossil repository’s web interface instead of the default |
|
116
|
IIS web site, as before you did all of the above. |
|
117
|
|
|
118
|
This is a very simple configuration. You can do more complicated and |
|
119
|
interesting things with this, such as redirecting only `/code` URLs to |
|
120
|
Fossil by setting the Pattern in step 6 to “`^/code(.*)$`”. (You would |
|
121
|
also need to pass `--baseurl http://example.com/code` in the `fossil |
|
122
|
server` command to make this work properly.) IIS would then directly |
|
123
|
serve all other URLs. You could also intermix ASP.NET applications in |
|
124
|
the URL scheme in this way. |
|
125
|
|
|
126
|
See the documentation on [URL Rewrite rules][urr] for more ideas. |
|
127
|
|
|
128
|
*[Return to the top-level Fossil server article.](../)* |
|
129
|
|
|
130
|
|
|
131
|
[arr]: https://www.iis.net/downloads/microsoft/application-request-routing |
|
132
|
[tls]: https://docs.microsoft.com/en-us/iis/manage/configuring-security/understanding-iis-url-authorization |
|
133
|
[ure]: https://www.iis.net/downloads/microsoft/url-rewrite |
|
134
|
[urr]: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module |
|
135
|
|