|
1 | 1 | //! Bindings to NGINX
|
| 2 | +//! |
2 | 3 | //! This project provides Rust SDK interfaces to the [NGINX](https://nginx.com) proxy allowing the creation of NGINX
|
3 | 4 | //! dynamic modules completely in Rust.
|
4 | 5 | //!
|
|
14 | 15 | //! * `NGX_DEBUG` (default to false) - if set to true, then will compile NGINX `--with-debug` option
|
15 | 16 | //!
|
16 | 17 | //! For example, this is how you would compile the [examples](https://github.com/nginxinc/ngx-rust/tree/master/examples) using a specific version of NGINX and enabling
|
17 |
| -//! debugging: `NGX_DEBUG=true NGX_VERSION=1.23.0 cargo build --package=examples --examples --release` |
| 18 | +//! debugging: |
| 19 | +//! ```sh |
| 20 | +//! NGX_DEBUG=true NGX_VERSION=1.23.0 cargo build --package=examples --examples --release |
| 21 | +//! ``` |
18 | 22 | //!
|
19 |
| -//! To build Linux-only modules, use the "linux" feature: `cargo build --package=examples --examples --features=linux --release` |
| 23 | +//! To build Linux-only modules, use the "linux" feature: |
| 24 | +//! ```sh |
| 25 | +//! cargo build --package=examples --examples --features=linux --release |
| 26 | +//! ``` |
20 | 27 | //!
|
21 | 28 | //! After compilation, the modules can be found in the path `target/release/examples/` ( with the `.so` file extension for
|
22 | 29 | //! Linux or `.dylib` for MacOS).
|
23 | 30 | //!
|
24 |
| -//! Additionally, the folder `.cache/nginx/{NGX_VERSION}/{OS}/` will contain the compiled version of NGINX used to build |
25 |
| -//! the SDK. You can start NGINX directly from this directory if you want to test the module or add it to `$PATH` |
| 31 | +//! Additionally, the folder `.cache/nginx/{NGX_VERSION}/{TARGET}` (`{TARGET}` means rustc's target triple string) |
| 32 | +//! will contain the compiled version of NGINX used to build the SDK. |
| 33 | +//! You can start NGINX directly from this directory if you want to test the module or add it to `$PATH` |
26 | 34 | //! ```not_rust
|
27 | 35 | //! $ export NGX_VERSION=1.23.3
|
28 | 36 | //! $ cargo build --package=examples --examples --features=linux --release
|
29 |
| -//! $ export PATH=$PATH:`pwd`/.cache/nginx/$NGX_VERSION/macos-x86_64/sbin |
| 37 | +//! $ export PATH=$PATH:$PWD/.cache/nginx/$NGX_VERSION/x86_64-unknown-linux-gnu/sbin |
30 | 38 | //! $ nginx -V
|
31 | 39 | //! $ ls -la ./target/release/examples/
|
32 | 40 | //! # now you can use dynamic modules with the NGINX
|
33 | 41 | //! ```
|
| 42 | +//! |
| 43 | +//! The following environment variables can be used to change locations of cache directory and NGINX directory: |
| 44 | +//! |
| 45 | +//! * `CACHE_DIR` (default `[nginx-sys's root directory]/.cache`) - the directory containing cache files, means PGP keys, tarballs, PGP signatures, and unpacked source codes. It also contains compiled NGINX in default configuration. |
| 46 | +//! * `NGINX_INSTALL_ROOT_DIR` (default `{CACHE_DIR}/nginx`) - the directory containing the series of compiled NGINX in its subdirectories |
| 47 | +//! * `NGINX_INSTALL_DIR` (default `{NGINX_INSTALL_BASE_DIR}/{NGX_VERSION}/{TARGET}`) - the directory containing the NGINX compiled in the build |
| 48 | +//! |
| 49 | +//! ### Mac OS dependencies |
| 50 | +//! |
| 51 | +//! In order to use the optional GNU make build process on MacOS, you will need to install additional tools. This can be |
| 52 | +//! done via [homebrew](https://brew.sh/) with the following command: |
| 53 | +//! ```sh |
| 54 | +//! brew install make openssl grep |
| 55 | +//! ``` |
| 56 | +//! |
| 57 | +//! Additionally, you may need to set up LLVM and clang. Typically, this is done as follows: |
| 58 | +//! |
| 59 | +//! ```sh |
| 60 | +//! # make sure xcode tools are installed |
| 61 | +//! xcode-select --install |
| 62 | +//! # instal llvm |
| 63 | +//! brew install --with-toolchain llvm |
| 64 | +//! ``` |
| 65 | +//! |
| 66 | +//! ### Linux dependencies |
| 67 | +//! |
| 68 | +//! See the [Dockerfile] for dependencies as an example of required packages on Debian Linux. |
| 69 | +//! |
| 70 | +//! [Dockerfile]: https://github.com/nginxinc/ngx-rust/blob/master/Dockerfile |
| 71 | +//! |
| 72 | +//! ### Build with external NGINX source tree |
| 73 | +//! |
| 74 | +//! If you require a customized NGINX configuration, you can build a module against an existing pre-configured source tree. |
| 75 | +//! To do that, you need to set the `NGX_OBJS` variable to an _absolute_ path of the NGINX build directory (`--builddir`, defaults to the `objs` in the source directory). |
| 76 | +//! Only the `./configure` step of the NGINX build is mandatory because bindings don't depend on any of the artifacts generated by `make`. |
| 77 | +//! |
| 78 | +//! ```sh |
| 79 | +//! NGX_OBJS=$PWD/../nginx/objs cargo build --package=examples --examples |
| 80 | +//! ``` |
| 81 | +//! |
| 82 | +//! Furthermore, this approach can be leveraged to build a module as a part of the NGINX build process by adding the `--add-module`/`--add-dynamic-module` options to the configure script. |
| 83 | +//! See the following example integration scripts: [`examples/config`] and [`examples/config.make`]. |
| 84 | +//! |
| 85 | +//! [`examples/config`]: https://github.com/nginxinc/ngx-rust/blob/master/examples/config |
| 86 | +//! [`examples/config.make`]: https://github.com/nginxinc/ngx-rust/blob/master/examples/config.make |
34 | 87 |
|
35 | 88 | #![warn(missing_docs)]
|
36 | 89 | /// The core module.
|
|
0 commit comments