Skip to content

Commit 3c38cbc

Browse files
committed
update http proxy documentation
1 parent 42dd494 commit 3c38cbc

File tree

1 file changed

+73
-6
lines changed

1 file changed

+73
-6
lines changed

README.md

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,80 @@ modifications to make it more suitable for local development work.
1010
A DNS resolver is also added. By default it will resolve all `*.docker` domains
1111
to the Docker VM, but this can be changed.
1212

13+
## Configuration
14+
15+
### Exposed Ports
16+
17+
The proxy will by default use the first port exposed by your container as the
18+
HTTP port to proxy to. This can be overridden by setting the VIRTUAL_PORT
19+
environment variable on the container to the desired HTTP port.
20+
21+
### Docker Compose Projects
22+
23+
The proxy will auto-generate a hostname based on the docker tags that
24+
docker-compose adds to each container. This hostname is of the form
25+
`<service>.<project>.<tld>`. For instance, assuming the default `*.docker` TLD,
26+
a "web" service in a "myapp" docker-compose project will be automatically made
27+
available at http://web.myapp.docker/.
28+
29+
### Explicitly Setting a Hostname
30+
1331
As in the base nginx-proxy, you can configure a container's hostname by setting
14-
the `VIRTUAL_HOST` environment variable in the container. In addition, this
15-
proxy also auto-creates hostnames for docker-compose projects. The format is
16-
`<container_name>.<compose_project_name>.<tld>`. For example, for a container
17-
named `web` in a docker-compose project named `myapp`, you can visit
18-
http://web.myapp.docker to be proxied to that container, without setting
19-
`VIRTUAL_HOST`.
32+
the `VIRTUAL_HOST` environment variable in the container.
33+
34+
You can set the `VIRTUAL_HOST`
35+
environment variable either with the `-e` option to docker or
36+
the environment hash in docker-compose. For instance setting
37+
`VIRTUAL_HOST=myrailsapp.docker` will make the container's exposed port
38+
available at http://myrailsapp.docker/.
39+
40+
This will work even if dinghy auto-generates a hostname based on the
41+
docker-compose tags.
42+
43+
### Subdomain Support
44+
45+
If you want your container to also be available at all subdomains to the given
46+
domain, prefix a dot `.` to the provided hostname. For instance setting
47+
`VIRTUAL_HOST=.myrailsapp.docker` will also make your app avaiable at
48+
`*.myrailsapp.docker`.
49+
50+
### SSL Support
51+
52+
SSL is supported using single host certificates using naming conventions.
53+
54+
To enable SSL, just put your certificates and privates keys in the ```HOME/.dinghy/certs``` directory
55+
for any virtual hosts in use. The certificate and keys should be named after the virtual host with a `.crt` and
56+
`.key` extension. For example, a container with `VIRTUAL_HOST=foo.bar.com.docker` should have a
57+
`foo.bar.com.docker.crt` and `foo.bar.com.docker.key` file in the certs directory.
58+
59+
#### How SSL Support Works
60+
61+
The SSL cipher configuration is based on [mozilla nginx intermediate profile](https://wiki.mozilla.org/Security/Server_Side_TLS#Nginx) which
62+
should provide compatibility with clients back to Firefox 1, Chrome 1, IE 7, Opera 5, Safari 1,
63+
Windows XP IE8, Android 2.3, Java 7. The configuration also enables HSTS, and SSL
64+
session caches.
65+
66+
The default behavior for the proxy when port 80 and 443 are exposed is as follows:
67+
68+
* If a container has a usable cert, port 80 will redirect to 443 for that container so that HTTPS
69+
is always preferred when available.
70+
* If the container does not have a usable cert, port 80 will be used.
71+
72+
To serve traffic in both SSL and non-SSL modes without redirecting to SSL, you can include the
73+
environment variable `HTTPS_METHOD=noredirect` (the default is `HTTPS_METHOD=redirect`). You can also
74+
disable the non-SSL site entirely with `HTTPS_METHOD=nohttp`.
75+
76+
#### How to quickly generate self-signed certificates
77+
78+
You can generate self-signed certificates using ```openssl```.
79+
80+
```bash
81+
openssl req -x509 -newkey rsa:2048 -keyout foo.bar.com.docker.key \
82+
-out foo.bar.com.docker.crt -days 365 -nodes \
83+
-subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=foo.bar.com.docker"
84+
```
85+
86+
To prevent your browser to emit warning regarding self-signed certificates, you can install them on your system as trusted certificates.
2087

2188
## Using Outside of Dinghy
2289

0 commit comments

Comments
 (0)