|
|
6928218 |
Nginx 1.12 server and a reverse proxy server container image
|
|
|
18c49f3 |
=========================================================
|
|
|
87766c4 |
|
|
|
18c49f3 |
This container image includes Nginx 1.12 server and a reverse server for OpenShift and general usage.
|
|
|
18c49f3 |
Users can choose RHEL based image.
|
|
|
18c49f3 |
The RHEL image is available in the [Red Hat Container Catalog](https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/nginx-112-rhel7)
|
|
|
18c49f3 |
as registry.access.redhat.com/rhscl/nginx-112-rhel7.
|
|
|
18c49f3 |
|
|
|
18c49f3 |
|
|
|
18c49f3 |
Description
|
|
|
18c49f3 |
-----------
|
|
|
18c49f3 |
|
|
|
18c49f3 |
Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP
|
|
|
18c49f3 |
protocols, with a strong focus on high concurrency, performance and low memory usage. The container
|
|
|
18c49f3 |
image provides a containerized packaging of the nginx 1.12 daemon. The image can be used
|
|
|
18c49f3 |
as a base image for other applications based on nginx 1.12 web server.
|
|
|
18c49f3 |
Nginx server image can be extended using source-to-image tool.
|
|
|
18c49f3 |
|
|
|
18c49f3 |
|
|
|
18c49f3 |
Usage
|
|
|
18c49f3 |
-----
|
|
|
18c49f3 |
|
|
|
18c49f3 |
To build a simple [sample-app](https://github.com/sclorg/nginx-container/tree/master/1.12/test/test-app) application
|
|
|
18c49f3 |
using standalone [S2I](https://github.com/openshift/source-to-image) and then run the
|
|
|
18c49f3 |
resulting image with [Docker](http://docker.io) execute:
|
|
|
18c49f3 |
|
|
|
18c49f3 |
* **For RHEL based image**
|
|
|
18c49f3 |
```
|
|
|
18c49f3 |
$ s2i build https://github.com/sclorg/nginx-container.git --context-dir=1.12/test/test-app/ rhscl/nginx-112-rhel7 nginx-sample-app
|
|
|
18c49f3 |
$ docker run -p 8080:8080 nginx-sample-app
|
|
|
18c49f3 |
```
|
|
|
18c49f3 |
|
|
|
18c49f3 |
* **For CentOS based image**
|
|
|
18c49f3 |
```
|
|
|
18c49f3 |
$ s2i build https://github.com/sclorg/nginx-container.git --context-dir=1.12/test/test-app/ centos/nginx-112-centos7 nginx-sample-app
|
|
|
18c49f3 |
$ docker run -p 8080:8080 nginx-sample-app
|
|
|
18c49f3 |
```
|
|
|
18c49f3 |
|
|
|
18c49f3 |
**Accessing the application:**
|
|
|
18c49f3 |
```
|
|
|
18c49f3 |
$ curl 127.0.0.1:8080
|
|
|
18c49f3 |
```
|
|
|
18c49f3 |
|
|
|
18c49f3 |
|
|
|
18c49f3 |
S2I build support
|
|
|
18c49f3 |
-------------
|
|
|
18c49f3 |
Nginx server image can be extended using S2I tool (see Usage section).
|
|
|
18c49f3 |
S2I build folder structure:
|
|
|
18c49f3 |
|
|
|
6928218 |
**`./nginx.conf`**--
|
|
|
6928218 |
The main nginx configuration file
|
|
|
6928218 |
|
|
|
6928218 |
**`./nginx-cfg/*.conf`**
|
|
|
6928218 |
Should contain all nginx configuration we want to include into image
|
|
|
6928218 |
|
|
|
6928218 |
**`./nginx-default-cfg/*.conf`**
|
|
|
6928218 |
Contains any nginx config snippets to include in the default server block
|
|
|
6928218 |
|
|
|
6928218 |
**`./nginx-start/*.sh`**
|
|
|
6928218 |
Contains shell scripts that are sourced right before nginx is launched
|
|
|
6928218 |
|
|
|
6928218 |
**`./`**
|
|
|
6928218 |
Should contain nginx application source code
|
|
|
6928218 |
|
|
|
18c49f3 |
|
|
|
18c49f3 |
Environment variables and volumes
|
|
|
18c49f3 |
-------------
|
|
|
18c49f3 |
The nginx container image supports the following configuration variable, which can be set by using the `-e` option with the docker run command:
|
|
|
18c49f3 |
|
|
|
18c49f3 |
|
|
|
6928218 |
**`NGINX_LOG_TO_VOLUME`**
|
|
|
6928218 |
When `NGINX_LOG_TO_VOLUME` is set, nginx logs into `/var/opt/rh/rh-nginx112/log/nginx/`
|
|
|
6928218 |
|
|
|
6928218 |
|
|
|
6928218 |
You can mount your own web root like this:
|
|
|
6928218 |
```
|
|
|
6928218 |
$ docker run -v <DIR>:/var/www/html/ <container>
|
|
|
6928218 |
```
|
|
|
6928218 |
You can replace \<DIR> with location of your web root. Please note that this has to be an **absolute** path, due to Docker requirements.
|
|
|
18c49f3 |
|
|
|
18c49f3 |
|
|
|
18c49f3 |
Troubleshooting
|
|
|
18c49f3 |
---------------
|
|
|
18c49f3 |
By default, nginx logs into standard output, so the log is available in the container log. The log can be examined by running:
|
|
|
18c49f3 |
|
|
|
18c49f3 |
docker logs <container>
|
|
|
18c49f3 |
|
|
|
6928218 |
**If `NGINX_LOG_TO_VOLUME` variable is set, nginx logs into `/var/opt/rh/rh-nginx112/log/nginx/`, which can be mounted to host system using the container volumes.**
|
|
|
18c49f3 |
|
|
|
18c49f3 |
|
|
|
18c49f3 |
See also
|
|
|
18c49f3 |
--------
|
|
|
18c49f3 |
Dockerfile and other sources for this container image are available on
|
|
|
18c49f3 |
https://github.com/sclorg/nginx-container.
|
|
|
18c49f3 |
In that repository, Dockerfile for CentOS is called Dockerfile, Dockerfile
|
|
|
18c49f3 |
for RHEL is called Dockerfile.rhel7.
|