You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `serve` command is useful when you want to preview your book. It also does hot reloading of the webpage whenever a file changes.
4
+
It achieves this by serving the books content over `localhost:3000` (unless otherwise configured, see below) and runs a websocket server on `localhost:3001` which triggers the reloads.
5
+
This preferred by many for writing books with mdbook because it allows for you to see the result of your work instantly after every file change.
6
+
7
+
#### Specify a directory
8
+
9
+
Like `watch`, `serve` can take a directory as argument to use instead of the
10
+
current working directory.
11
+
12
+
```bash
13
+
mdbook serve path/to/book
14
+
```
15
+
16
+
17
+
#### Server options
18
+
19
+
`serve` has four options: the http port, the websocket port, the interface to serve on, and the public address of the server so that the browser may reach the websocket server.
20
+
21
+
For example: suppose you had an nginx server for SSL termination which has a public address of 192.168.1.100 on port 80 and proxied that to 127.0.0.1 on port 8000. To run use the nginx proxy do:
22
+
23
+
```bash
24
+
mdbook server path/to/book -p 8000 -i 127.0.0.1 -a 192.168.1.100
25
+
```
26
+
27
+
If you were to want live reloading for this you would need to proxy the websocket calls through nginx as well from `192.168.1.100:<WS_PORT>` to `127.0.0.1:<WS_PORT>`. The `-w` flag allows for the websocket port to be configured.
28
+
29
+
-----
30
+
31
+
***note:****the `serve` command has not gotten a lot of testing yet, there could be some rough edges. If you discover a problem, please report it [on Github](https://github.com/azerupi/mdBook/issues)*
0 commit comments