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
@@ -30,15 +30,17 @@ Many editors support that file natively. Others require a plugin, see https://ed
30
30
31
31
Be sure to run any tests:
32
32
33
-
```shell
33
+
```terminal
34
34
cargo test
35
35
```
36
36
37
+
With gcc v15 you may need to set the environment variable `CFLAGS="-Wno-error=unterminated-string-initialization"` to avoid a warning failing the build.
38
+
37
39
### Staying in sync with upstream
38
40
39
41
When your branch gets out of sync with the glyn/nginx_robot_access/main branch, use the following to update:
Copy file name to clipboardExpand all lines: README.md
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,29 +15,35 @@ This module is written in Rust. After [installing Rust](https://www.rust-lang.or
15
15
the module may be built using `cargo`, but **must** be built for the version of NGINX that is in use.
16
16
17
17
For example, to build the module for NGINX version 1.22.1, issue the following command in the root directory of a clone of this repository:
18
-
~~~
18
+
19
+
~~~terminal
19
20
NGX_VERSION=1.22.1 cargo build --release
20
21
~~~
21
22
23
+
With gcc v15 you may also need to set the environment variable `CFLAGS="-Wno-error=unterminated-string-initialization"` to avoid a warning failing the build.
24
+
22
25
This will build a shared library in `target/release`.
23
26
24
27
## Configuring
25
28
26
29
To enable this module, it must be loaded in the NGINX configuration, e.g.:
27
-
~~~
30
+
31
+
~~~config
28
32
load_module /var/lib/libnginx_robot_access.so;
29
33
~~~
30
34
31
35
For this module to work correctly, the absolute file path of `robots.txt` must be configured in the NGINX configuration using the directive `robots_txt_path`. The directive takes a single argument: the absolute file path of `robots.txt`, e.g.:
32
-
~~~
36
+
37
+
~~~config
33
38
robots_txt_path /etc/robots.txt;
34
39
~~~
35
40
36
41
The directive may be specified in any of the `http`, `server`, or `location` configuration blocks.
37
42
Configuring the directive in the `location` block overrides any configuration of the directive in the `server` block. Configuring the directive in the `server` block overrides any configuration in the `http` block.
38
43
39
44
For example, here's a simple configuration that enables the module and sets the path to `/etc/robots.txt`:
40
-
~~~
45
+
46
+
~~~config
41
47
load_module /var/lib/libnginx_robot_access.so;
42
48
...
43
49
http {
@@ -54,14 +60,16 @@ http {
54
60
## Validating
55
61
56
62
To make sure the module is working correctly, use `curl` to access your site and specify a user agent that your `robots.txt` file denies access for, e.g.:
57
-
~~~
63
+
64
+
~~~terminal
58
65
curl -A "GPTBot" https://example.org
59
66
~~~
60
67
61
68
## Debugging
62
69
63
70
Some debug logging is included in the module. To use this, enable debug logging in the NGINX configuration, e.g.:
0 commit comments