Skip to content

Commit 88faf0a

Browse files
committed
inets: Improve httpd documentation to use types
In the translation from xml to markdown the properties documentation for httpd was left as is, which does not look great in ex_doc. This commit moves type documentation from the moduledoc to specific types and extracts the mod_* docs into their respective module. As I did not want to migrate the mod_cgi and mod_action docs just for them to be removed later, they have been removed already in this doc refactor.
1 parent 7d1dfc9 commit 88faf0a

11 files changed

Lines changed: 605 additions & 830 deletions

File tree

lib/inets/doc/guides/hardening.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -339,16 +339,14 @@ list. The default is:
339339
Review this list and remove modules you do not need:
340340

341341
- **`mod_cgi`** and **`mod_actions`** - Enable CGI script execution.
342-
Deprecated in OTP 29 and scheduled for removal in OTP 30. If you still
343-
need CGI support, add them explicitly to your module list. CGI introduces a
344-
large attack surface (arbitrary process execution, environment variable
345-
injection).
342+
Removed in OTP 30. CGI introduces a large attack surface (arbitrary process
343+
execution, environment variable injection).
346344

347345
- **`mod_dir`** - Enables directory listing. Remove it to prevent information
348346
disclosure about your file structure.
349347

350348
- **`mod_esi`** - Enables Erlang Scripting Interface. If used, restrict it
351-
with [`erl_script_alias`](`m:httpd#prop_esi_alias`) to a whitelist of allowed modules.
349+
with [`erl_script_alias`](`m:mod_esi#prop_esi_alias`) to a whitelist of allowed modules.
352350

353351
- **`mod_trace`** - Handles HTTP TRACE requests. TRACE can be exploited in
354352
cross-site tracing (XST) attacks. This module is not in the default list
@@ -364,17 +362,17 @@ A minimal module chain for a static file server:
364362

365363
If using `mod_auth`:
366364

367-
- **Avoid [`{auth_type, plain}`](`m:httpd#prop_auth_type`)** in production. It stores passwords in
365+
- **Avoid [`{auth_type, plain}`](`m:mod_auth#prop_auth_type`)** in production. It stores passwords in
368366
cleartext files. Prefer `dets` or `mnesia`.
369367

370-
- **Place auth files outside `document_root`**. The [`auth_user_file`](`m:httpd#prop_auth_user_file`) and
371-
[`auth_group_file`](`m:httpd#prop_auth_group_file`) must not be accessible via HTTP.
368+
- **Place auth files outside `document_root`**. The [`auth_user_file`](`m:mod_auth#prop_auth_user_file`) and
369+
[`auth_group_file`](`m:mod_auth#prop_auth_group_file`) must not be accessible via HTTP.
372370

373-
- **Set [`auth_access_password`](`m:httpd#prop_auth_access_passwd`)** to a strong value. When not set or set to
371+
- **Set [`auth_access_password`](`m:mod_auth#prop_auth_access_passwd`)** to a strong value. When not set or set to
374372
`"NoPassword"`, no password is required for the authentication management
375373
API.
376374

377-
- **Use IP-based restrictions** ([`allow_from`](`m:httpd#prop_allow_from`), [`deny_from`](`m:httpd#prop_deny_from`)) as an additional
375+
- **Use IP-based restrictions** ([`allow_from`](`m:mod_auth#prop_allow_from`), [`deny_from`](`m:mod_auth#prop_deny_from`)) as an additional
378376
layer, not as the sole access control mechanism.
379377

380378
> #### Warning {: .warning }
@@ -401,21 +399,21 @@ Enable `mod_security` to throttle authentication brute force attempts:
401399
]}}
402400
```
403401

404-
- **[`data_file`](`m:httpd#prop_data_file`)** - Path to the persistent security
402+
- **[`data_file`](`m:mod_security#prop_data_file`)** - Path to the persistent security
405403
data file. Store this outside `document_root`. Required for `mod_security`
406404
to persist blocked-user state across server restarts.
407405

408-
- **[`max_retries`](`m:httpd#prop_max_retries`)** - Maximum failed authentication
406+
- **[`max_retries`](`m:mod_security#prop_max_retries`)** - Maximum failed authentication
409407
attempts before the user is blocked. Default: `3`.
410408

411-
- **[`block_time`](`m:httpd#prop_block_time`)** - Minutes a blocked user remains
409+
- **[`block_time`](`m:mod_security#prop_block_time`)** - Minutes a blocked user remains
412410
locked out. Default: `60`.
413411

414-
- **[`fail_expire_time`](`m:httpd#prop_fail_exp_time`)** - Minutes before a
412+
- **[`fail_expire_time`](`m:mod_security#prop_fail_exp_time`)** - Minutes before a
415413
failed attempt is forgotten. If the user does not retry within this window,
416414
the failure counter resets. Default: `30`.
417415

418-
- **[`auth_timeout`](`m:httpd#prop_auth_timeout`)** - Seconds a successful
416+
- **[`auth_timeout`](`m:mod_security#prop_auth_timeout`)** - Seconds a successful
419417
authentication is remembered. After expiry the user must re-authenticate.
420418
Default: `30`.
421419

@@ -428,13 +426,13 @@ Enable `mod_security` to throttle authentication brute force attempts:
428426
For runtime inspection and manual blocking, see `m:mod_security`
429427
([`list_blocked_users/1`](`mod_security:list_blocked_users/1`), [`block_user/5`](`mod_security:block_user/5`), [`unblock_user/4`](`mod_security:unblock_user/4`)).
430428

431-
### CGI and ESI Execution
429+
### ESI Execution
432430

433-
- **[`script_alias`](`m:httpd#prop_script_alias`)** maps URL paths to CGI script directories. Ensure the
431+
- **`script_alias`** maps URL paths to ESI script directories. Ensure the
434432
mapped directory contains only intended scripts and is not writable by the
435433
web server process.
436434

437-
- **[`erl_script_alias`](`m:httpd#prop_esi_alias`)** controls which Erlang modules can be called via ESI.
435+
- **[`erl_script_alias`](`m:mod_esi#prop_esi_alias`)** controls which Erlang modules can be called via ESI.
438436
Always specify an explicit whitelist:
439437

440438
```erlang
@@ -443,10 +441,10 @@ For runtime inspection and manual blocking, see `m:mod_security`
443441

444442
Never use a wildcard or overly broad module list.
445443

446-
- **[`script_timeout`](`m:httpd#prop_script_timeout`)** and **[`erl_script_timeout`](`m:httpd#prop_esi_timeout`)** default to 15 seconds.
444+
- **`script_timeout`** and **[`erl_script_timeout`](`m:mod_esi#prop_esi_timeout`)** default to 15 seconds.
447445
Review whether this is appropriate for your use case.
448446

449-
- **[`script_nocache`](`m:httpd#prop_script_nocache`)** and **[`erl_script_nocache`](`m:httpd#prop_esi_nocache`)** - When set to `true`, the
447+
- **`script_nocache`** and **[`erl_script_nocache`](`m:mod_esi#prop_esi_nocache`)** - When set to `true`, the
450448
server adds HTTP header fields preventing proxies from caching dynamic
451449
responses. Default: `false`. Enable these to prevent stale or sensitive
452450
dynamic content from being served from proxy caches.
@@ -455,8 +453,8 @@ For runtime inspection and manual blocking, see `m:mod_security`
455453
>
456454
> The `script_alias` path resolution can bypass `mod_auth` directory
457455
> protections depending on module ordering. Ensure `mod_auth` appears
458-
> before `mod_cgi` in the module chain, and test that authentication
459-
> is enforced on CGI paths.
456+
> before `mod_esi` in the module chain, and test that authentication
457+
> is enforced on ESI paths.
460458
461459
### Logging
462460

lib/inets/doc/guides/http_server.md

Lines changed: 15 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ The server implements numerous features, such as:
3434

3535
- Secure Sockets Layer (SSL)
3636
- Erlang Scripting Interface (ESI)
37-
- Common Gateway Interface (CGI)
3837
- User Authentication (using Mnesia, Dets or plain text database)
3938
- Common Logfile Format (with or without disk_log(3) support)
4039
- URL Aliasing
@@ -43,10 +42,10 @@ The server implements numerous features, such as:
4342

4443
The configuration of the server is provided as an Erlang property list.
4544

46-
As of `Inets` 5\.0 the HTTP server is an easy to start/stop and customize web
45+
The HTTP server is an easy to start/stop and customize web
4746
server providing the most basic web server functionality. Inets is designed for
4847
embedded systems and if you want a full-fledged web server there are other
49-
erlang open source alternatives.
48+
Erlang open source alternatives.
5049

5150
Almost all server functionality has been implemented using an especially crafted
5251
server API, which is described in the Erlang Web Server API. This API can be
@@ -165,45 +164,14 @@ and cannot be the hostname that is allowed when putting in `bind_address`.
165164
`Inets` HTTP server provides two ways of creating dynamic web pages, each with
166165
its own advantages and disadvantages:
167166

168-
- **_CGI scripts (deprecated)_** - Common Gateway Interface (CGI) scripts can be written in
169-
any programming language. CGI scripts are standardized and supported by most
170-
web servers. The drawback with CGI scripts is that they are resource-intensive
171-
because of their design. CGI requires the server to fork a new OS process for
172-
each executable it needs to start.
173-
174167
- **_ESI-functions_** - Erlang Server Interface (ESI) functions provide a tight
175168
and efficient interface to the execution of Erlang functions. This interface,
176169
on the other hand, is `Inets` specific.
177170

178171
### CGI Version 1.1, RFC 3875
179172

180173
> #### Note {: .info }
181-
> `mod_cgi` and `mod_actions` are deprecated since OTP 29 and will be removed in OTP 30.
182-
> Use `mod_esi` instead for dynamic page generation.
183-
>
184-
185-
The module `mod_cgi` enables execution of
186-
[CGI scripts](http://www.ietf.org/rfc/rfc3875.txt) on the server. A file
187-
matching the definition of a ScriptAlias config directive is treated as a CGI
188-
script. A CGI script is executed by the server and its output is returned to the
189-
client.
190-
191-
The CGI script response comprises a message header and a message body, separated
192-
by a blank line. The message header contains one or more header fields. The body
193-
can be empty.
194-
195-
Example:
196-
197-
```text
198-
"Content-Type:text/plain\nAccept-Ranges:none\n\nsome very
199-
plain text"
200-
```
201-
202-
The server interprets the message headers and most of them are transformed into
203-
HTTP headers and sent back to the client together with the message-body.
204-
205-
Support for CGI-1.1 is implemented in accordance with
206-
[RFC 3875](http://www.ietf.org/rfc/rfc3875.txt).
174+
> `mod_cgi` and `mod_actions` are removed since OTP 39.
207175

208176
### ESI
209177

@@ -318,26 +286,8 @@ of these modules is to be present in the module directive. Notice that there are
318286
some interaction dependencies to take into account, so the order of the modules
319287
cannot be random.
320288

321-
### mod_actions - Filetype/Method-Based Script Execution
322-
323-
> #### Note {: .info }
324-
> `mod_cgi` and `mod_actions` are deprecated since OTP 29 and will be removed in OTP 30.
325-
> Use `mod_esi` instead for dynamic page generation.
326-
>
327-
328-
This module runs CGI scripts whenever a file of a certain type or HTTP method
329-
(see [RFC 1945](http://tools.ietf.org/html/rfc1945)) is requested.
330-
331-
Uses the following Erlang Web Server API interaction data:
332-
333-
- `real_name` \- from `m:mod_alias`.
334-
335-
Exports the following Erlang Web Server API interaction data, if possible:
336-
337-
- **`{new_request_uri, RequestURI}`** - An alternative `RequestURI` has been
338-
generated.
339-
340289
### mod_alias - URL Aliasing
290+
{: #mod_alias }
341291

342292
The `m:mod_alias` module makes it possible to map different parts of the host
343293
file system into the document tree, that is, creates aliases and redirections.
@@ -348,6 +298,7 @@ Exports the following Erlang Web Server API interaction data, if possible:
348298
`mod_alias:path/3`.
349299

350300
### mod_auth - User Authentication
301+
{: #mod_auth }
351302

352303
The `m:mod_auth` module provides for basic user authentication using textual
353304
files, Dets databases as well as Mnesia databases.
@@ -411,16 +362,8 @@ the HTTP server. If they are placed in the directory which it protects, clients
411362
can download the tables. Only the Dets and Mnesia storage methods allow writing
412363
of dynamic user data to disk. `plain` is a read only method.
413364

414-
### mod_cgi - CGI Scripts
415-
416-
> #### Note {: .info }
417-
> `mod_cgi` and `mod_actions` are deprecated since OTP 29 and will be removed in OTP 30.
418-
> Use `mod_esi` instead for dynamic page generation.
419-
>
420-
421-
This module handles invoking of CGI scripts.
422-
423365
### mod_dir - Directories
366+
{: #mod_dir }
424367

425368
This module generates an HTML directory listing (Apache-style) if a client sends
426369
a request for a directory instead of a file. This module must be removed from
@@ -436,6 +379,7 @@ Exports the following Erlang Web Server API interaction data:
436379
a `MimeType`.
437380

438381
### mod_disk_log - Logging Using Disk_Log.
382+
{: #mod_disk_log }
439383

440384
Standard logging using the "Common Logfile Format" and `m:disk_log`.
441385

@@ -444,6 +388,7 @@ Uses the following Erlang Web Server API interaction data:
444388
- `remote_user` \- from `mod_auth`
445389

446390
### mod_esi - Erlang Server Interface
391+
{: #mod_esi }
447392

448393
The `m:mod_esi` module implements the Erlang Server Interface (ESI) providing a
449394
tight and efficient interface to the execution of Erlang functions.
@@ -458,6 +403,7 @@ Exports the following Erlang web server API interaction data:
458403
a `MimeType`
459404

460405
### mod_get - Regular GET Requests
406+
{: #mod_get }
461407

462408
This module is responsible for handling GET requests to regular files. GET
463409
requests for parts of files is handled by `mod_range`.
@@ -467,6 +413,7 @@ Uses the following Erlang web server API interaction data:
467413
- `real_name` \- from `m:mod_alias`
468414

469415
### mod_head - Regular HEAD Requests
416+
{: #mod_head }
470417

471418
This module is responsible for handling HEAD requests to regular files. HEAD
472419
requests for dynamic content is handled by each module responsible for dynamic
@@ -477,6 +424,7 @@ Uses the following Erlang Web Server API interaction data:
477424
- `real_name` \- from `m:mod_alias`
478425

479426
### mod_log - Logging Using Text Files.
427+
{: #mod_log }
480428

481429
Standard logging using the "Common Logfile Format" and text files.
482430

@@ -485,6 +433,7 @@ Uses the following Erlang Web Server API interaction data:
485433
- `remote_user` \- from `mod_auth`
486434

487435
### mod_range - Requests with Range Headers
436+
{: #mod_range }
488437

489438
This module responses to requests for one or many ranges of a file. This is
490439
especially useful when downloading large files, as a broken download can be
@@ -498,6 +447,7 @@ Uses the following Erlang Web Server API interaction data:
498447
- `real_name` \- from `m:mod_alias`
499448

500449
### mod_responsecontrol - Requests with If\* Headers
450+
{: #mod_responsecontrol }
501451

502452
This module controls that the conditions in the requests are fulfilled. For
503453
example, a request can specify that the answer only is of interest if the
@@ -529,6 +479,7 @@ Exports the following Erlang Web Server API interaction data:
529479
must be treated as an ordinary get request.
530480

531481
### mod_security - Security Filter
482+
{: #mod_security }
532483

533484
The `m:mod_security` module serves as a filter for authenticated requests
534485
handled in `m:mod_auth`. It provides a possibility to restrict users from access
@@ -541,6 +492,7 @@ blocked users or users who have been authenticated within a configurable amount
541492
of time.
542493

543494
### mod_trace - TRACE Request
495+
{: #mod_trace }
544496

545497
`mod_trace` is responsible for handling of TRACE requests. Trace is a new
546498
request method in HTTP/1.1. The intended use of trace requests is for testing.

lib/inets/doc/notes.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,7 +2627,7 @@ limitations under the License.
26272627

26282628
`ossl` will work for as long as the ssl application supports it.
26292629

2630-
See the httpd [socket_type](`m:httpd#props_comm`) communication property or
2630+
See the httpd [socket_type](`m:httpd#prop_socket_type`) communication property or
26312631
the httpc [request/4,5](`httpc:request/4`) function for more info.
26322632

26332633
Own Id: OTP-9230
@@ -2636,7 +2636,7 @@ limitations under the License.
26362636

26372637
### Fixed Bugs and Malfunctions
26382638

2639-
- \[httpd] Wrong [security property](`m:httpd#props_sec`) names used in
2639+
- \[httpd] Wrong [security property](`t:mod_security:security_option/0`) names used in
26402640
documentation.
26412641

26422642
`security_data_file` used instead of `data_file`.
@@ -2762,7 +2762,7 @@ limitations under the License.
27622762
instead.
27632763

27642764
See the `http_option` option in the [request/4,5](`httpc:request/4`) or the
2765-
[socket-type](`m:httpd#props_comm`) section of the Communication properties
2765+
[socket_type](`m:httpd#prop_socket_type`) section of the Communication properties
27662766
chapter for more info,
27672767

27682768
Own Id: OTP-7907
@@ -2777,8 +2777,8 @@ limitations under the License.
27772777

27782778
- \[httpd] - Improved mod_alias. Now able to do better URL rewrites.
27792779

2780-
See [URL aliasing properties](`m:httpd#props_alias`) and the
2781-
[CGI properties](`m:httpd#props_cgi`) section(s) for more info,
2780+
See [URL aliasing properties](`t:mod_alias:url_alias_option/0`) and the
2781+
CGI properties section(s) for more info,
27822782

27832783
Own Id: OTP-8573
27842784

@@ -3103,8 +3103,7 @@ limitations under the License.
31033103

31043104
Default is `inet6fb4` which emulates the behaviour of the previous version.
31053105

3106-
See the [Communication properties](`m:httpd#props_comm`) section for more
3107-
info.
3106+
See the [Communication properties](`t:httpd:communication_option/0`) section for more info.
31083107

31093108
Own Id: OTP-8069
31103109

0 commit comments

Comments
 (0)