Fossil SCM
Swapped the simple foo.net "whole site is Fossil" example in www/server/debian/nginx.md for the more complicated example.com one where only /code is served by Fossil. This is probably going to be more common, and it shows off the important detail of setting SCRIPT_NAME properly. Made a minor adjustment to any/scgi.md to track this change, so there is not a pointless difference between these two nginx configs.
Commit
653e90ca6277eea53426b6bd78d3f75bd319195b9e1e950f6a68e2ffc63e6dd0
Parent
5a58ac3141612f2…
2 files changed
+4
-4
+22
-18
+4
-4
| --- www/server/any/scgi.md | ||
| +++ www/server/any/scgi.md | ||
| @@ -9,27 +9,27 @@ | ||
| 9 | 9 | This can be used with a web server such as [nginx](http://nginx.org) |
| 10 | 10 | which does not support [Fossil’s CGI mode](./cgi.md). |
| 11 | 11 | |
| 12 | 12 | A basic nginx configuration to support SCGI with Fossil looks like this: |
| 13 | 13 | |
| 14 | - location /example/ { | |
| 14 | + location /code/ { | |
| 15 | 15 | include scgi_params; |
| 16 | - scgi_param SCRIPT_NAME "/example"; | |
| 16 | + scgi_param SCRIPT_NAME "/code"; | |
| 17 | 17 | scgi_pass localhost:9000; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | The `scgi_params` file comes with nginx, and it simply translates nginx |
| 21 | 21 | internal variables to `scgi_param` directives to create SCGI environment |
| 22 | 22 | variables for the proxied program; in this case, Fossil. Our explicit |
| 23 | 23 | `scgi_param` call to define `SCRIPT_NAME` adds one more variable to this |
| 24 | 24 | set, which is necessary for this configuration to work properly, because |
| 25 | 25 | our repo isn’t at the root of the URL hierarchy. Without it, when Fossil |
| 26 | -generates absolute URLs, they’ll be missing the `/example` part at the | |
| 26 | +generates absolute URLs, they’ll be missing the `/code` part at the | |
| 27 | 27 | start, which will typically cause [404 errors][404]. |
| 28 | 28 | |
| 29 | 29 | The final directive simply tells nginx to proxy all calls to URLs under |
| 30 | -`/example` down to an SCGI program on TCP port 9000. We can temporarily | |
| 30 | +`/code` down to an SCGI program on TCP port 9000. We can temporarily | |
| 31 | 31 | set Fossil up as a server on that port like so: |
| 32 | 32 | |
| 33 | 33 | $ fossil server /path/to/repo.fossil --scgi --localhost --port 9000 & |
| 34 | 34 | |
| 35 | 35 | The `--scgi` option switches Fossil into SCGI mode from its default, |
| 36 | 36 |
| --- www/server/any/scgi.md | |
| +++ www/server/any/scgi.md | |
| @@ -9,27 +9,27 @@ | |
| 9 | This can be used with a web server such as [nginx](http://nginx.org) |
| 10 | which does not support [Fossil’s CGI mode](./cgi.md). |
| 11 | |
| 12 | A basic nginx configuration to support SCGI with Fossil looks like this: |
| 13 | |
| 14 | location /example/ { |
| 15 | include scgi_params; |
| 16 | scgi_param SCRIPT_NAME "/example"; |
| 17 | scgi_pass localhost:9000; |
| 18 | } |
| 19 | |
| 20 | The `scgi_params` file comes with nginx, and it simply translates nginx |
| 21 | internal variables to `scgi_param` directives to create SCGI environment |
| 22 | variables for the proxied program; in this case, Fossil. Our explicit |
| 23 | `scgi_param` call to define `SCRIPT_NAME` adds one more variable to this |
| 24 | set, which is necessary for this configuration to work properly, because |
| 25 | our repo isn’t at the root of the URL hierarchy. Without it, when Fossil |
| 26 | generates absolute URLs, they’ll be missing the `/example` part at the |
| 27 | start, which will typically cause [404 errors][404]. |
| 28 | |
| 29 | The final directive simply tells nginx to proxy all calls to URLs under |
| 30 | `/example` down to an SCGI program on TCP port 9000. We can temporarily |
| 31 | set Fossil up as a server on that port like so: |
| 32 | |
| 33 | $ fossil server /path/to/repo.fossil --scgi --localhost --port 9000 & |
| 34 | |
| 35 | The `--scgi` option switches Fossil into SCGI mode from its default, |
| 36 |
| --- www/server/any/scgi.md | |
| +++ www/server/any/scgi.md | |
| @@ -9,27 +9,27 @@ | |
| 9 | This can be used with a web server such as [nginx](http://nginx.org) |
| 10 | which does not support [Fossil’s CGI mode](./cgi.md). |
| 11 | |
| 12 | A basic nginx configuration to support SCGI with Fossil looks like this: |
| 13 | |
| 14 | location /code/ { |
| 15 | include scgi_params; |
| 16 | scgi_param SCRIPT_NAME "/code"; |
| 17 | scgi_pass localhost:9000; |
| 18 | } |
| 19 | |
| 20 | The `scgi_params` file comes with nginx, and it simply translates nginx |
| 21 | internal variables to `scgi_param` directives to create SCGI environment |
| 22 | variables for the proxied program; in this case, Fossil. Our explicit |
| 23 | `scgi_param` call to define `SCRIPT_NAME` adds one more variable to this |
| 24 | set, which is necessary for this configuration to work properly, because |
| 25 | our repo isn’t at the root of the URL hierarchy. Without it, when Fossil |
| 26 | generates absolute URLs, they’ll be missing the `/code` part at the |
| 27 | start, which will typically cause [404 errors][404]. |
| 28 | |
| 29 | The final directive simply tells nginx to proxy all calls to URLs under |
| 30 | `/code` down to an SCGI program on TCP port 9000. We can temporarily |
| 31 | set Fossil up as a server on that port like so: |
| 32 | |
| 33 | $ fossil server /path/to/repo.fossil --scgi --localhost --port 9000 & |
| 34 | |
| 35 | The `--scgi` option switches Fossil into SCGI mode from its default, |
| 36 |
+22
-18
| --- www/server/debian/nginx.md | ||
| +++ www/server/debian/nginx.md | ||
| @@ -161,49 +161,53 @@ | ||
| 161 | 161 | On Debian and Ubuntu systems the primary user-level configuration file |
| 162 | 162 | for nginx is `/etc/nginx/sites-enabled/default`. I recommend that this |
| 163 | 163 | file contain only a list of include statements, one for each site that |
| 164 | 164 | server hosts: |
| 165 | 165 | |
| 166 | - include local/example | |
| 167 | - include local/foo | |
| 166 | + include local/example.com | |
| 167 | + include local/foo.net | |
| 168 | 168 | |
| 169 | 169 | Those files then each define one domain’s configuration. Here, |
| 170 | -`/etc/nginx/local/example` contains the configuration for | |
| 171 | -`*.example.com` and `*.example.net`; and `local/foo` contains the | |
| 172 | -configuration for `*.foo.net`. | |
| 170 | +`/etc/nginx/local/example.com` contains the configuration for | |
| 171 | +`*.example.com` and its alias `*.example.net`; and `local/foo.net` | |
| 172 | +contains the configuration for `*.foo.net`. | |
| 173 | 173 | |
| 174 | -The configuration for our `foo.net` web site, stored in | |
| 175 | -`/etc/nginx/sites-enabled/local/foo` is: | |
| 174 | +The configuration for our `example.com` web site, stored in | |
| 175 | +`/etc/nginx/sites-enabled/local/example.com` is: | |
| 176 | 176 | |
| 177 | 177 | server { |
| 178 | - server_name .foo.net; | |
| 178 | + server_name .example.com .example.net ""; | |
| 179 | 179 | include local/generic; |
| 180 | 180 | |
| 181 | - access_log /var/log/nginx/foo.net-https-access.log; | |
| 182 | - error_log /var/log/nginx/foo.net-https-error.log; | |
| 181 | + access_log /var/log/nginx/example.com-https-access.log; | |
| 182 | + error_log /var/log/nginx/example.com-https-error.log; | |
| 183 | 183 | |
| 184 | - # Bypass Fossil for the static Doxygen docs | |
| 185 | - location /doc/html { | |
| 186 | - root /var/www/foo.net; | |
| 184 | + # Bypass Fossil for the static documentation generated from | |
| 185 | + # our source code by Doxygen, so it merges into the embedded | |
| 186 | + # doc URL hierarchy at Fossil’s $ROOT/doc without requiring that | |
| 187 | + # these generated files actually be stored in the repo. This | |
| 188 | + # also lets us set aggressive caching on these docs, since | |
| 189 | + # they rarely change. | |
| 190 | + location /code/doc/html { | |
| 191 | + root /var/www/example.com/code/doc/html; | |
| 187 | 192 | |
| 188 | 193 | location ~* \.(html|ico|css|js|gif|jpg|png)$ { |
| 189 | 194 | expires 7d; |
| 190 | 195 | add_header Vary Accept-Encoding; |
| 191 | 196 | access_log off; |
| 192 | 197 | } |
| 193 | 198 | } |
| 194 | 199 | |
| 195 | 200 | # Redirect everything else to the Fossil instance |
| 196 | - location / { | |
| 201 | + location /code { | |
| 197 | 202 | include scgi_params; |
| 203 | + scgi_param SCRIPT_NAME "/code"; | |
| 198 | 204 | scgi_pass 127.0.0.1:12345; |
| 199 | - scgi_param HTTPS "on"; | |
| 200 | - scgi_param SCRIPT_NAME ""; | |
| 201 | 205 | } |
| 202 | 206 | } |
| 203 | 207 | |
| 204 | -As you can see, this is a simple extension of [the basic nginx service | |
| 208 | +As you can see, this is a pure extension of [the basic nginx service | |
| 205 | 209 | configuration for SCGI][scgii], showing off a few ideas you might want to |
| 206 | 210 | try on your own site, such as static asset proxying. |
| 207 | 211 | |
| 208 | 212 | The `local/generic` file referenced above helps us reduce unnecessary |
| 209 | 213 | repetition among the multiple sites this configuration hosts: |
| @@ -221,10 +225,10 @@ | ||
| 221 | 225 | the `access_log` and `error_log` directives, which follow an obvious |
| 222 | 226 | pattern from one host to the next. Sadly, you must tolerate some |
| 223 | 227 | repetition across `server { }` blocks when setting up multiple domains |
| 224 | 228 | on a single server. |
| 225 | 229 | |
| 226 | -The configuration for `example.com` and `example.net` is similar. | |
| 230 | +The configuration for `foo.net` is similar. | |
| 227 | 231 | |
| 228 | 232 | See [the nginx docs](http://nginx.org/en/docs/) for more ideas. |
| 229 | 233 | |
| 230 | 234 | *[Return to the top-level Fossil server article.](../)* |
| 231 | 235 |
| --- www/server/debian/nginx.md | |
| +++ www/server/debian/nginx.md | |
| @@ -161,49 +161,53 @@ | |
| 161 | On Debian and Ubuntu systems the primary user-level configuration file |
| 162 | for nginx is `/etc/nginx/sites-enabled/default`. I recommend that this |
| 163 | file contain only a list of include statements, one for each site that |
| 164 | server hosts: |
| 165 | |
| 166 | include local/example |
| 167 | include local/foo |
| 168 | |
| 169 | Those files then each define one domain’s configuration. Here, |
| 170 | `/etc/nginx/local/example` contains the configuration for |
| 171 | `*.example.com` and `*.example.net`; and `local/foo` contains the |
| 172 | configuration for `*.foo.net`. |
| 173 | |
| 174 | The configuration for our `foo.net` web site, stored in |
| 175 | `/etc/nginx/sites-enabled/local/foo` is: |
| 176 | |
| 177 | server { |
| 178 | server_name .foo.net; |
| 179 | include local/generic; |
| 180 | |
| 181 | access_log /var/log/nginx/foo.net-https-access.log; |
| 182 | error_log /var/log/nginx/foo.net-https-error.log; |
| 183 | |
| 184 | # Bypass Fossil for the static Doxygen docs |
| 185 | location /doc/html { |
| 186 | root /var/www/foo.net; |
| 187 | |
| 188 | location ~* \.(html|ico|css|js|gif|jpg|png)$ { |
| 189 | expires 7d; |
| 190 | add_header Vary Accept-Encoding; |
| 191 | access_log off; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | # Redirect everything else to the Fossil instance |
| 196 | location / { |
| 197 | include scgi_params; |
| 198 | scgi_pass 127.0.0.1:12345; |
| 199 | scgi_param HTTPS "on"; |
| 200 | scgi_param SCRIPT_NAME ""; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | As you can see, this is a simple extension of [the basic nginx service |
| 205 | configuration for SCGI][scgii], showing off a few ideas you might want to |
| 206 | try on your own site, such as static asset proxying. |
| 207 | |
| 208 | The `local/generic` file referenced above helps us reduce unnecessary |
| 209 | repetition among the multiple sites this configuration hosts: |
| @@ -221,10 +225,10 @@ | |
| 221 | the `access_log` and `error_log` directives, which follow an obvious |
| 222 | pattern from one host to the next. Sadly, you must tolerate some |
| 223 | repetition across `server { }` blocks when setting up multiple domains |
| 224 | on a single server. |
| 225 | |
| 226 | The configuration for `example.com` and `example.net` is similar. |
| 227 | |
| 228 | See [the nginx docs](http://nginx.org/en/docs/) for more ideas. |
| 229 | |
| 230 | *[Return to the top-level Fossil server article.](../)* |
| 231 |
| --- www/server/debian/nginx.md | |
| +++ www/server/debian/nginx.md | |
| @@ -161,49 +161,53 @@ | |
| 161 | On Debian and Ubuntu systems the primary user-level configuration file |
| 162 | for nginx is `/etc/nginx/sites-enabled/default`. I recommend that this |
| 163 | file contain only a list of include statements, one for each site that |
| 164 | server hosts: |
| 165 | |
| 166 | include local/example.com |
| 167 | include local/foo.net |
| 168 | |
| 169 | Those files then each define one domain’s configuration. Here, |
| 170 | `/etc/nginx/local/example.com` contains the configuration for |
| 171 | `*.example.com` and its alias `*.example.net`; and `local/foo.net` |
| 172 | contains the configuration for `*.foo.net`. |
| 173 | |
| 174 | The configuration for our `example.com` web site, stored in |
| 175 | `/etc/nginx/sites-enabled/local/example.com` is: |
| 176 | |
| 177 | server { |
| 178 | server_name .example.com .example.net ""; |
| 179 | include local/generic; |
| 180 | |
| 181 | access_log /var/log/nginx/example.com-https-access.log; |
| 182 | error_log /var/log/nginx/example.com-https-error.log; |
| 183 | |
| 184 | # Bypass Fossil for the static documentation generated from |
| 185 | # our source code by Doxygen, so it merges into the embedded |
| 186 | # doc URL hierarchy at Fossil’s $ROOT/doc without requiring that |
| 187 | # these generated files actually be stored in the repo. This |
| 188 | # also lets us set aggressive caching on these docs, since |
| 189 | # they rarely change. |
| 190 | location /code/doc/html { |
| 191 | root /var/www/example.com/code/doc/html; |
| 192 | |
| 193 | location ~* \.(html|ico|css|js|gif|jpg|png)$ { |
| 194 | expires 7d; |
| 195 | add_header Vary Accept-Encoding; |
| 196 | access_log off; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | # Redirect everything else to the Fossil instance |
| 201 | location /code { |
| 202 | include scgi_params; |
| 203 | scgi_param SCRIPT_NAME "/code"; |
| 204 | scgi_pass 127.0.0.1:12345; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | As you can see, this is a pure extension of [the basic nginx service |
| 209 | configuration for SCGI][scgii], showing off a few ideas you might want to |
| 210 | try on your own site, such as static asset proxying. |
| 211 | |
| 212 | The `local/generic` file referenced above helps us reduce unnecessary |
| 213 | repetition among the multiple sites this configuration hosts: |
| @@ -221,10 +225,10 @@ | |
| 225 | the `access_log` and `error_log` directives, which follow an obvious |
| 226 | pattern from one host to the next. Sadly, you must tolerate some |
| 227 | repetition across `server { }` blocks when setting up multiple domains |
| 228 | on a single server. |
| 229 | |
| 230 | The configuration for `foo.net` is similar. |
| 231 | |
| 232 | See [the nginx docs](http://nginx.org/en/docs/) for more ideas. |
| 233 | |
| 234 | *[Return to the top-level Fossil server article.](../)* |
| 235 |