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
Copy file name to clipboardExpand all lines: README.md
+12-72Lines changed: 12 additions & 72 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,14 +25,12 @@ When using nginx, there are many **legitimate reasons** to support `.htaccess` f
25
25
***Justified.** Apache performs multiple file reads anyway, so .htaccess for nginx cannot make it worse than Apache, right? In fact, with our built-in micro caching mechanism both, CPU and I/O load are reduced drastically compared to Apache's implementation.
26
26
***For webhosters.** Today, webhosters still need to provide an interface for their customers to change certain aspects of their webserver's behaviour. The decades long and proven `.htaccess` file does just that.
27
27
28
-
29
28
## Performance
30
29
31
30
**.htaccess for nginx is incredibly lightweight and fast!** It is written from the ground up with performance optimizations in mind. Even with low-end hardware it adds less than 1 millisecond to your response time, despite supporting quite complex rewrite structures with server variables.
32
31
33
32
Physical memory usage of this plugin is insanely low, under 10 KB for each nginx worker process, and it doesn't increase with more requests.
34
33
35
-
36
34
## Requirements
37
35
38
36
* Debian or Fedora environment
@@ -44,11 +42,11 @@ Physical memory usage of this plugin is insanely low, under 10 KB for each nginx
44
42
45
43
## Installation
46
44
47
-
1. Install nginx with the [Lua module](https://github.com/openresty/lua-nginx-module)`libnginx-mod-http-lua` and the `luajit`package.
3. Add the following configuration to the nginx `http {}` context:
63
+
5. Add the following configuration to the nginx `http {}` context:
66
64
```nginx
67
65
http {
68
66
...
69
67
lua_shared_dict htaccess 16m;
68
+
69
+
# This is useful for debugging but may cause performance problems
70
+
# lua_code_cache off;
70
71
...
71
72
}
72
73
```
73
74
This represents a caching system, used on a short-term per-request basis. `.htaccess` lines are usually cached as values forless than 100 milliseconds, but keptin memory as long as there are active connections. You can choose to assign any other memory amount to it, although 16 MB should be more than enough.
74
-
4. Configure the nginx `server {}` context(s) to use the plugin:
75
+
6. Configure the nginx `server {}` context(s) to use the plugin:
75
76
```nginx
76
77
server {
77
78
...
@@ -242,7 +243,7 @@ mod_negotiation | `ForceLanguagePriority` | No |
242
243
mod_negotiation |`LanguagePriority`| No |
243
244
mod_reflector |`*`| Never | Security reasons
244
245
mod_rewrite |`RewriteBase`| Yes |
245
-
mod_rewrite |`RewriteCond`| Partial | Environment (E=) flag is unsupported, as are *CondPattern* integer comparisons and some file attribute tests listed in the [documentation](https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html)
246
+
mod_rewrite |`RewriteCond`| Partial | Environment (E=) flag is unsupported, as are *CondPattern* integer comparisons and some file attribute tests listed in the [documentation](https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html).
246
247
mod_rewrite |`RewriteEngine`| Yes |
247
248
mod_rewrite |`RewriteOptions`| No |
248
249
mod_rewrite |`RewriteRule`| Yes |
@@ -321,64 +322,3 @@ Variables not listed below are not supported.
321
322
...
322
323
}
323
324
```
324
-
325
-
326
-
## Debugging Lua inside a Docker container
327
-
328
-
Using IntelliJ IDEA, you can remotely debug Lua scripts like `htaccess.lua` running in an nginx Docker container, using [these steps](https://dev.to/omervk/debugging-lua-inside-openresty-inside-docker-with-intellij-idea-2h95). In particular, this has been tested on a Windows 10 host running IntelliJ IDEA 2022.2.4 (Community Edition), with the `fabiocicerchia/nginx-lua:1.23.2-almalinux8.7-20221201` Docker image from https://hub.docker.com/r/fabiocicerchia/nginx-lua.
329
-
330
-
It assumes you are mapping a host path of `C:\path\to\project\on\windows` to a path in the container volume of `/path/to/project`.
1. In IDEA, create a Run/Debug configuration per the link and then start the debugger
383
-
384
-
When you request a URL that triggers the Lua script, it will pause on the `dbg.breakHere()` line so you can step through the code, watch variables, etc.
0 commit comments