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
&& sed -i'''s|^\s*include.*conf\.d/.*| include /etc/httpd-custom.d/*.conf;\n include /etc/httpd/conf.d/*.conf;\n include /etc/httpd/vhost.d/*.conf;\n|g' /etc/nginx/nginx.conf
68
+
&& sed -i'''s|^\s*include.*conf\.d/.*| include /etc/httpd-custom.d/*.conf;\n include /etc/httpd/conf.d/*.conf;\n include /etc/httpd/vhost.d/*.conf;\n|g' /etc/nginx/nginx.conf \
[](https://gitter.im/devilbox/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
This image is based on the official **[Nginx](https://hub.docker.com/_/nginx)** Docker image and extends it with the ability to have **virtual hosts created automatically**, as well as **adding SSL certificates** when creating new directories. For that to work, it integrates two tools that will take care about the whole process: **[watcherd](https://github.com/devilbox/watcherd)** and **[vhost-gen](https://github.com/devilbox/vhost-gen)**.
10
12
11
-
This image is based on the official **[Nginx (stable)](https://hub.docker.com/_/nginx/)** Docker image and extends it with the ability to have **virtual hosts created automatically** when adding new directories. For that to work, it integrates two tools that will take care about the whole process: **[watcherd](https://github.com/devilbox/watcherd)** and **[vhost-gen](https://github.com/devilbox/vhost-gen)**.
13
+
From a users perspective, you mount your local project directory into the container under `/shared/httpd`. Any directory then created in your local project directory wil spawn a new virtual host by the same name. Additional settings such as custom server names, PHP-FPM or even different Apache templates per project are supported as well.
12
14
13
-
From a users perspective, you mount your local project directory into the Docker under `/shared/httpd`. Any directory then created in your local project directory wil spawn a new virtual host by the same name. Additional settings such as custom server names, PHP-FPM or even different nginx templates per project are supported as well.
@@ -29,12 +27,16 @@ Find me on **[Docker Hub](https://hub.docker.com/r/devilbox/nginx-stable)**:
29
27
30
28
1. Automated virtual hosts can be enabled by providing `-e MASS_VHOST_ENABLE=1`.
31
29
2. You should mount a local project directory into the Docker under `/shared/httpd` (`-v /local/path:/shared/httpd`).
32
-
3. You can optionally specify a global server name suffix via e.g.: `-e MASS_VHOST_TLD=.local`
30
+
3. You can optionally specify a global server name suffix via e.g.: `-e MASS_VHOST_TLD=.loc`
33
31
4. You can optionally specify a global subdirectory from which the virtual host will servve the documents via e.g.: `-e MASS_VHOST_DOCROOT=www`
34
-
4. Allow the Docker to expose its port via `-p 80:80`.
35
-
5. Have DNS names point to the IP address the docker runs on (e.g. via `/etc/hosts`)
32
+
5. Allow the Docker to expose its port via `-p 80:80`.
33
+
6. Have DNS names point to the IP address the container runs on (e.g. via `/etc/hosts`)
36
34
37
-
With the above described settings, whenever you create a local directory under your projects dir, such as `/local/path/mydir`, there will be a new virtual host created by the same name `http://mydir`. You can also specify a global suffix for the vhost names via `-e MASS_VHOST_TLD=.local`, afterwards your above created vhost would be reachable via `http://mydir.local`.
35
+
With the above described settings, whenever you create a local directory under your projects dir
36
+
such as `/local/path/mydir`, there will be a new virtual host created by the same name
37
+
`http://mydir`. You can also specify a global suffix for the vhost names via
38
+
`-e MASS_VHOST_TLD=.loc`, afterwards your above created vhost would be reachable via
39
+
`http://mydir.loc`.
38
40
39
41
Just to give you a few examples:
40
42
@@ -67,7 +69,7 @@ docker run -it \
67
69
-p 80:80 \
68
70
-e MASS_VHOST_ENABLE=1 \
69
71
-e MASS_VHOST_DOCROOT=www \
70
-
-e MASS_VHOST_TLD=.local \
72
+
-e MASS_VHOST_TLD=.loc \
71
73
-v /local/path:/shared/httpd \
72
74
devilbox/nginx-stable
73
75
```
@@ -99,7 +101,7 @@ PHP-FPM is not included inside this Docker container, but can be enabled to cont
99
101
100
102
#### Disabling the default virtual host
101
103
102
-
If you only want to server you custom projects and don't need the default virtual host, you can disable it by `-e MAIN_VHOST_DISABLE=1`.
104
+
If you only want to server you custom projects and don't need the default virtual host, you can disable it by `-e MAIN_VHOST_ENABLE=0`.
103
105
104
106
105
107
## Options
@@ -130,7 +132,10 @@ This Docker container adds a lot of injectables in order to customize it to your
130
132
131
133
| Variable | Type | Default | Description |
132
134
|----------|------|---------|-------------|
133
-
| MAIN_VHOST_DISABLE | bool |`0`| By default there is a standard (catch-all) vhost configured to accept requests served from `/var/www/default/htdocs`. If you want to disable it, set the value to `1`.<br/><strong>Note:</strong>The `htdocs` dir name can be changed with `MAIN_VHOST_DOCROOT`. See below. |
135
+
| MAIN_VHOST_ENABLE | bool |`1`| By default there is a standard (catch-all) vhost configured to accept requests served from `/var/www/default/htdocs`. If you want to disable it, set the value to `0`.<br/><strong>Note:</strong>The `htdocs` dir name can be changed with `MAIN_VHOST_DOCROOT`. See below. |
136
+
| MAIN_VHOST_SSL_TYPE | string |`plain`| <ul><li><code>plain</code> - only serve via http</li><li><code>ssl</code> - only serve via https</li><li><code>both</code> - serve via http and https</li><li><code>redir</code> - serve via https and redirect http to https</li></ul> |
137
+
| MAIN_VHOST_SSL_GEN | bool |`0`|`0`: Do not generate an ssl certificate<br/> `1`: Generate self-signed certificate automatically |
138
+
| MAIN_VHOST_SSL_CN | string |`localhost`| Comma separated list of CN names for SSL certificate generation (The domain names by which you want to reach the default server) |
134
139
| MAIN_VHOST_DOCROOT | string |`htdocs`| This is the directory name appended to `/var/www/default/` from which the default virtual host will serve its files.<br/><strong>Default:</strong><br/>`/var/www/default/htdocs`<br/><strong>Example:</strong><br/>`MAIN_VHOST_DOCROOT=www`<br/>Doc root: `/var/www/default/www`|
135
140
| MAIN_VHOST_TPL | string |`cfg`| Directory within th default vhost base path (`/var/www/default`) to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.<br/><strong>Resulting default path:</strong><br/>`/var/www/default/cfg`|
136
141
| MAIN_VHOST_STATUS_ENABLE | bool |`0`| Enable httpd status page. |
@@ -141,7 +146,9 @@ This Docker container adds a lot of injectables in order to customize it to your
141
146
| Variable | Type | Default | Description |
142
147
|----------|------|---------|-------------|
143
148
| MASS_VHOST_ENABLE | bool |`0`| You can enable mass virtual hosts by setting this value to `1`. Mass virtual hosts will be created for each directory present in `/shared/httpd` by the same name including a top-level domain suffix (which could also be a domain+tld). See `MASS_VHOST_TLD` for how to set it. |
144
-
| MASS_VHOST_TLD | string |`.local`| This string will be appended to the server name (which is built by its directory name) for mass virtual hosts and together build the final domain.<br/><strong>Default:</strong>`<project>.local`<br/><strong>Example:</strong><br/>Path: `/shared/httpd/temp`<br/>`MASS_VHOST_TLD=.lan`<br/>Server name: `temp.lan`<br/><strong>Example:</strong><br/>Path:`/shared/httpd/api`<br/>`MASS_VHOST_TLD=.example.com`<br/>Server name: `api.example.com`|
149
+
| MASS_VHOST_SSL_TYPE | string |`plain`| <ul><li><code>plain</code> - only serve via http</li><li><code>ssl</code> - only serve via https</li><li><code>both</code> - serve via http and https</li><li><code>redir</code> - serve via https and redirect http to https</li></ul> |
150
+
| MASS_VHOST_SSL_GEN | bool |`0`|`0`: Do not generate an ssl certificate<br/> `1`: Generate self-signed certificate automatically |
151
+
| MASS_VHOST_TLD | string |`.loc`| This string will be appended to the server name (which is built by its directory name) for mass virtual hosts and together build the final domain.<br/><strong>Default:</strong>`<project>.loc`<br/><strong>Example:</strong><br/>Path: `/shared/httpd/temp`<br/>`MASS_VHOST_TLD=.lan`<br/>Server name: `temp.lan`<br/><strong>Example:</strong><br/>Path:`/shared/httpd/api`<br/>`MASS_VHOST_TLD=.example.com`<br/>Server name: `api.example.com`|
145
152
| MASS_VHOST_DOCROOT | string |`htdocs`| This is a subdirectory within your project dir under each project from which the web server will serve its files.<br/>`/shared/httpd/<project>/$MASS_VHOST_DOCROOT/`<br/><strong>Default:</strong><br/>`/shared/httpd/<project>/htdocs/`|
146
153
| MASS_VHOST_TPL | string |`cfg`| Directory within your new virtual host to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.<br/>`/shared/httpd/<project>/$MASS_VHOST_TPL/`<br/><strong>Resulting default path:</strong><br/>`/shared/httpd/<project>/cfg/`|
147
154
@@ -159,7 +166,8 @@ This Docker container adds a lot of injectables in order to customize it to your
159
166
160
167
| Docker | Description |
161
168
|--------|-------------|
162
-
| 80 | Nginx listening Port |
169
+
| 80 | HTTP listening Port |
170
+
| 443 | HTTPS listening Port |
163
171
164
172
165
173
## Examples
@@ -247,8 +255,5 @@ It allows any of the following combinations:
0 commit comments