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
{{ message }}
This repository was archived by the owner on Jan 11, 2025. It is now read-only.
**Note:** The full list of supported/unsupported tags can be found on [`docs/TAGS.md`](https://github.com/fabiocicerchia/nginx-lua/blob/master/docs/TAGS.md).
40
40
41
41
## Quick reference (cont.)
42
42
43
-
-**Where to file issues:**[https://github.com/fabiocicerchia/nginx-lua/issues](https://github.com/fabiocicerchia/nginx-lua/issues)
@@ -111,12 +111,16 @@ Lua is a lightweight, high-level, multi-paradigm programming language designed p
111
111
```console
112
112
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d fabiocicerchia/nginx-lua
113
113
```
114
+
114
115
Alternatively, a simple `Dockerfile` can be used to generate a new image that includes the necessary content (which is a much cleaner solution than the bind mount above):
116
+
115
117
```dockerfile
116
118
FROM fabiocicerchia/nginx-lua
117
119
COPY static-html-directory /usr/share/nginx/html
118
120
```
121
+
119
122
Place this file in the same directory as your directory of content ("static-html-directory"), run `docker build -t some-content-nginx .`, then start your container:
123
+
120
124
```console
121
125
$ docker run --name some-nginx -d some-content-nginx
$ docker run --name some-nginx -d -p 8080:80 some-content-nginx
128
132
```
133
+
129
134
Then you can hit `http://localhost:8080` or `http://host-ip:8080` in your browser.
130
135
131
136
### Complex configuration
132
137
133
138
```console
134
139
$ docker run --name my-custom-nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d fabiocicerchia/nginx-lua
135
140
```
141
+
136
142
For information on the syntax of the nginx configuration files, see [the official documentation](http://nginx.org/en/docs/) (specifically the [Beginner's Guide](http://nginx.org/en/docs/beginners_guide.html#conf_structure)).
137
143
If you wish to adapt the default configuration, use something like the following to copy it from a running nginx container:
144
+
138
145
```console
139
146
$ docker run --name tmp-nginx-container -d fabiocicerchia/nginx-lua
This can also be accomplished more cleanly using a simple `Dockerfile` (in `/host/path/`):
152
+
144
153
```dockerfile
145
154
FROM fabiocicerchia/nginx-lua
146
155
COPY nginx.conf /etc/nginx/nginx.conf
147
156
```
157
+
148
158
If you add a custom `CMD` in the Dockerfile, be sure to include `-g daemon off;` in the `CMD` in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)!
149
159
Then build the image with `docker build -t custom-nginx .` and run it as follows:
160
+
150
161
```console
151
162
$ docker run --name my-custom-nginx-container -d custom-nginx
152
163
```
164
+
153
165
#### Using environment variables in nginx configuration (new in 1.19)
154
166
155
167
Out-of-the-box, nginx doesn't support environment variables inside most configuration blocks. But this image has a function, which will extract environment variables before nginx starts.
156
168
Here is an example using docker-compose.yml:
169
+
157
170
```yaml
158
171
web:
159
172
image: fabiocicerchia/nginx-lua
@@ -165,30 +178,41 @@ web:
165
178
- NGINX_HOST=foobar.com
166
179
- NGINX_PORT=80
167
180
```
181
+
168
182
By default, this function reads template files in `/etc/nginx/templates/*.template` and outputs the result of executing `envsubst` to `/etc/nginx/conf.d`.
169
183
So if you place `templates/default.conf.template` file, which contains variable references like this:
170
-
listen ${NGINX_PORT};
184
+
185
+
```
186
+
listen ${NGINX_PORT};
187
+
```
188
+
171
189
outputs to `/etc/nginx/conf.d/default.conf` like this:
172
-
listen 80;
190
+
191
+
```
192
+
listen 80;
193
+
```
194
+
173
195
This behavior can be changed via the following environment variables:
174
-
-`NGINX_ENVSUBST_TEMPLATE_DIR`
175
-
- A directory which contains template files (default: `/etc/nginx/templates`)
176
-
- When this directory doesn't exist, this function will do nothing about template processing.
177
-
-`NGINX_ENVSUBST_TEMPLATE_SUFFIX`
178
-
- A suffix of template files (default: `.template`)
179
-
- This function only processes the files whose name ends with this suffix.
180
-
-`NGINX_ENVSUBST_OUTPUT_DIR`
181
-
- A directory where the result of executing envsubst is output (default: `/etc/nginx/conf.d`)
182
-
- The output filename is the template filename with the suffix removed.
183
-
- ex.) `/etc/nginx/templates/default.conf.template` will be output with the filename `/etc/nginx/conf.d/default.conf`.
184
-
- This directory must be writable by the user running a container.
196
+
-`NGINX_ENVSUBST_TEMPLATE_DIR`
197
+
- A directory which contains template files (default: `/etc/nginx/templates`)
198
+
- When this directory doesn't exist, this function will do nothing about template processing.
199
+
-`NGINX_ENVSUBST_TEMPLATE_SUFFIX`
200
+
- A suffix of template files (default: `.template`)
201
+
- This function only processes the files whose name ends with this suffix.
202
+
-`NGINX_ENVSUBST_OUTPUT_DIR`
203
+
- A directory where the result of executing envsubst is output (default: `/etc/nginx/conf.d`)
204
+
- The output filename is the template filename with the suffix removed.
205
+
- ex.) `/etc/nginx/templates/default.conf.template` will be output with the filename `/etc/nginx/conf.d/default.conf`.
206
+
- This directory must be writable by the user running a container.
185
207
186
208
### Running nginx in read-only mode
187
209
188
210
To run nginx in read-only mode, you will need to mount a Docker volume to every location where nginx writes information. The default nginx configuration requires write access to `/var/cache` and `/var/run`. This can be easily accomplished by running nginx as follows:
If you have a more advanced configuration that requires nginx to write to other locations, simply add more volume mounts to those locations.
193
217
194
218
### Running nginx in debug mode
@@ -212,13 +236,15 @@ web:
212
236
### Entrypoint quiet logs
213
237
214
238
Since version 1.19.0, a verbose entrypoint was added. It provides information on what's happening during container startup. You can silence this output by setting environment variable `NGINX_ENTRYPOINT_QUIET_LOGS`:
239
+
215
240
```console
216
241
$ docker run -d -e NGINX_ENTRYPOINT_QUIET_LOGS=1 fabiocicerchia/nginx-lua
217
242
```
218
243
219
244
### User and group id
220
245
221
246
Since 1.17.0, both alpine- and debian-based images variants use the same user and group ids to drop the privileges for worker processes:
It is possible to run the image as a less privileged arbitrary UID/GID. This, however, requires modification of nginx configuration to use directories writeable by that specific UID/GID pair:
256
+
230
257
```console
231
258
$ docker run -d -v $PWD/nginx.conf:/etc/nginx/nginx.conf fabiocicerchia/nginx-lua
232
259
```
260
+
233
261
where nginx.conf in the current directory should have the following directives re-defined:
Provides Nginx + Lua. Uses pinned version for Alpine, Amazon Linux, CentOS, Debian, Fedora, Ubuntu for base image.
405
442
**WARNING:** Not available as tag, need manual build, see [Minimal Image](#minimal-image)
406
443
@@ -524,9 +561,9 @@ More details about the benchark can be found in [docs/benchmarks/distros](docs/b
524
561
525
562
Extract of [openresty/lua-nginx-module](https://github.com/openresty/lua-nginx-module) under [BSD license](https://github.com/openresty/lua-nginx-module#copyright-and-license).
526
563
527
-
- [LUA Nginx Module - Known Issues](docs/lua-nginx-module/known-issues.md)
Copy file name to clipboardexpand all lines: docs/BENCHMARKS.md
-1
Original file line number
Diff line number
Diff line change
@@ -15,4 +15,3 @@ More details about the benchark can be found in [docs/benchmarks/different_image
15
15

16
16
17
17
More details about the benchark can be found in [docs/benchmarks/distros](docs/benchmarks/distros).
0 commit comments