{"id":21606026,"url":"https://github.com/codekitchen/dinghy-http-proxy","last_synced_at":"2025-04-11T04:04:28.982Z","repository":{"id":31360610,"uuid":"34923498","full_name":"codekitchen/dinghy-http-proxy","owner":"codekitchen","description":"the http proxy container that dinghy uses","archived":false,"fork":false,"pushed_at":"2022-06-01T16:32:32.000Z","size":327,"stargazers_count":123,"open_issues_count":18,"forks_count":43,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-11T04:04:20.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codekitchen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-01T20:52:31.000Z","updated_at":"2025-01-03T21:51:05.000Z","dependencies_parsed_at":"2022-08-24T14:21:37.418Z","dependency_job_id":null,"html_url":"https://github.com/codekitchen/dinghy-http-proxy","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekitchen%2Fdinghy-http-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekitchen%2Fdinghy-http-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekitchen%2Fdinghy-http-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekitchen%2Fdinghy-http-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codekitchen","download_url":"https://codeload.github.com/codekitchen/dinghy-http-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339286,"owners_count":21087215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T20:18:38.159Z","updated_at":"2025-04-11T04:04:28.959Z","avatar_url":"https://github.com/codekitchen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dinghy HTTP Proxy\n\n[![Docker Automated build](https://img.shields.io/docker/automated/codekitchen/dinghy-http-proxy.svg)](https://hub.docker.com/r/codekitchen/dinghy-http-proxy/)\n\nThis is the HTTP Proxy and DNS server that\n[Dinghy](https://github.com/codekitchen/dinghy) uses.\n\nThe proxy is based on jwilder's excellent\n[nginx-proxy](https://github.com/jwilder/nginx-proxy) project, with\nmodifications to make it more suitable for local development work.\n\nA DNS resolver is also added. By default it will resolve all `*.docker` domains\nto the Docker VM, but this can be changed.\n\n## Configuration\n\n### Exposed Ports\n\nThe proxy will by default use the first port exposed by your container as the\nHTTP port to proxy to. This can be overridden by setting the VIRTUAL_PORT\nenvironment variable on the container to the desired HTTP port.\n\n### Docker Compose Projects\n\nThe proxy will auto-generate a hostname based on the docker tags that\ndocker-compose adds to each container. This hostname is of the form\n`\u003cservice\u003e.\u003cproject\u003e.\u003ctld\u003e`. For instance, assuming the default `*.docker` TLD,\na \"web\" service in a \"myapp\" docker-compose project will be automatically made\navailable at http://web.myapp.docker/.\n\n### Explicitly Setting a Hostname\n\nAs in the base nginx-proxy, you can configure a container's hostname by setting\nthe `VIRTUAL_HOST` environment variable in the container.\n\nYou can set the `VIRTUAL_HOST`\nenvironment variable either with the `-e` option to docker or\nthe environment hash in docker-compose. For instance setting\n`VIRTUAL_HOST=myrailsapp.docker` will make the container's exposed port\navailable at http://myrailsapp.docker/.\n\nThis will work even if dinghy auto-generates a hostname based on the\ndocker-compose tags.\n\n#### Multiple Hosts\n\nIf you need to support multiple virtual hosts for a container, you can separate each entry with commas.  For example, `foo.bar.com,baz.bar.com,bar.com` and each host will be setup the same.\n\nAdditionally you can customize the port for each host by appending a port\nnumber: `foo.bar.com,baz.bar.com:3000`.  Each name will point to its specified\nport and any name without a port will use the default.\n\n#### Wildcard Hosts\n\nYou can also use wildcards at the beginning and the end of host name, like `*.bar.com` or `foo.bar.*`. Or even a regular expression, which can be very useful in conjunction with a wildcard DNS service like [xip.io](http://xip.io), using `~^foo\\.bar\\..*\\.xip\\.io` will match `foo.bar.127.0.0.1.xip.io`, `foo.bar.10.0.2.2.xip.io` and all other given IPs. More information about this topic can be found in the nginx documentation about [`server_names`](http://nginx.org/en/docs/http/server_names.html).\n\n### Enabling CORS\n\nYou can set the `CORS_ENABLED`\nenvironment variable either with the `-e` option to docker or\nthe environment hash in docker-compose. For instance setting\n`CORS_ENABLED=true` will allow the container's web proxy to accept cross domain\nrequests.\n\nIf you want to be more specific, you can also set `CORS_DOMAINS` (along with `CORS_ENABLED`) to specify the domains you want to whitelist. They need to be separated using comma.\n\nThis is especially helpful when you have to deal with CORS with authenticated cross domain requests.\n\nMore information on this topic on [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers).\n\n### Subdomain Support\n\nIf you want your container to also be available at all subdomains to the given\ndomain, prefix a dot `.` to the provided hostname. For instance setting\n`VIRTUAL_HOST=.myrailsapp.docker` will also make your app avaiable at\n`*.myrailsapp.docker`.\n\nThis happens automatically for the auto-generated docker-compose hostnames.\n\n### SSL Support\n\nSSL is supported using single host certificates using naming conventions.\n\nTo enable SSL, just put your certificates and privates keys in the ```HOME/.dinghy/certs``` directory\nfor any virtual hosts in use.  The certificate and keys should be named after the virtual host with a `.crt` and\n`.key` extension.  For example, a container with `VIRTUAL_HOST=foo.bar.com.docker` should have a\n`foo.bar.com.docker.crt` and `foo.bar.com.docker.key` file in the certs directory.\n\n#### How SSL Support Works\n\nThe SSL cipher configuration is based on [mozilla nginx intermediate profile](https://wiki.mozilla.org/Security/Server_Side_TLS#Nginx) which\nshould provide compatibility with clients back to Firefox 1, Chrome 1, IE 7, Opera 5, Safari 1,\nWindows XP IE8, Android 2.3, Java 7.  The configuration also enables HSTS, and SSL\nsession caches.\n\nThe default behavior for the proxy when port 80 and 443 are exposed is as follows:\n\n* If a container has a usable cert, port 80 will redirect to 443 for that container so that HTTPS\nis always preferred when available.\n* If the container does not have a usable cert, port 80 will be used.\n\nTo serve traffic in both SSL and non-SSL modes without redirecting to SSL, you can include the\nenvironment variable `HTTPS_METHOD=noredirect` (the default is `HTTPS_METHOD=redirect`).  You can also\ndisable the non-SSL site entirely with `HTTPS_METHOD=nohttp`.\n\n#### How to quickly generate self-signed certificates\n\nYou can generate self-signed certificates using ```openssl```.\n\n```bash\nopenssl req -x509 -newkey rsa:2048 -keyout foo.bar.com.docker.key \\\n-out foo.bar.com.docker.crt -days 365 -nodes \\\n-subj \"/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=foo.bar.com.docker\" \\\n-config \u003c(cat /etc/ssl/openssl.cnf \u003c(printf \"[SAN]\\nsubjectAltName=DNS:foo.bar.com.docker\")) \\\n-reqexts SAN -extensions SAN\n```\n\nTo prevent your browser to emit warning regarding self-signed certificates, you can install them on your system as trusted certificates.\n\n## Using Outside of Dinghy\n\nSince this functionality is generally useful for local development work even\noutside of Dinghy, this proxy now supports running standalone.\n\n#### Environment variables\n\nWe include a few environment variables to customize the proxy / dns server:\n\n- `DOMAIN_TLD` default: `docker` - The DNS server will only respond to `*.docker` by default. You can change this to `dev` if it suits your workflow\n- `DNS_IP` default: `127.0.0.1` - Setting this variable is explained below\n\n### OS X\n\nYou'll need the IP of your VM:\n\n* For docker-machine, run `docker-machine ip \u003cmachine_name\u003e` to get the IP.\n* For Docker for Mac, you can use `127.0.0.1` as the IP, since it forwards docker ports to the host machine.\n\nThen start the proxy:\n\n    docker run -d --restart=always \\\n      -v /var/run/docker.sock:/tmp/docker.sock:ro \\\n      -v ~/.dinghy/certs:/etc/nginx/certs \\\n      -p 80:80 -p 443:443 -p 19322:19322/udp \\\n      -e DNS_IP=\u003cvm_ip\u003e -e CONTAINER_NAME=http-proxy \\\n      --name http-proxy \\\n      codekitchen/dinghy-http-proxy\n\nYou will also need to configure OS X to use the DNS resolver. To do this, create\na file `/etc/resolver/docker` (creating the `/etc/resolver` directory if it does\nnot exist) with these contents:\n\n```\nnameserver \u003cvm_ip\u003e\nport 19322\n```\n\nYou only need to do this step once, or when the VM's IP changes.\n\n### Linux\n\nFor running Docker directly on a Linux host machine, the proxy can still be\nuseful for easy access to your development environments. Similar to OS X, start\nthe proxy:\n\n    docker run -d --restart=always \\\n      -v /var/run/docker.sock:/tmp/docker.sock:ro \\\n      -v ~/.dinghy/certs:/etc/nginx/certs \\\n      -p 80:80 -p 443:443 -p 19322:19322/udp \\\n      -e CONTAINER_NAME=http-proxy \\\n      --name http-proxy \\\n      codekitchen/dinghy-http-proxy\n\nThe `DNS_IP` environment variable is not necessary when Docker is running\ndirectly on the host, as it defaults to `127.0.0.1`.\n\nDifferent Linux distributions will require different steps for configuring DNS\nresolution. The [Dory](https://github.com/FreedomBen/dory) project may be useful\nhere, it knows how to configure common distros for `dinghy-http-proxy`.\n\n### Windows\n\n* For Docker for Windows, you can use `127.0.0.1` as the DNS IP.\n\nFrom Powershell:\n```\ndocker run -d --restart=always `\n  -v /var/run/docker.sock:/tmp/docker.sock:ro `\n  -p 80:80 -p 443:443 -p 19322:19322/udp `\n  -e CONTAINER_NAME=http-proxy `\n  -e DNS_IP=127.0.0.1 `\n  --name http-proxy `\n  codekitchen/dinghy-http-proxy\n```\n\nFrom docker-compose:\n```\nversion: '2'\nservices:\n\n  http-proxy:\n    container_name: http-proxy\n    image: codekitchen/dinghy-http-proxy\n    environment:\n      - DNS_IP=127.0.0.1\n      - CONTAINER_NAME=http-proxy\n    ports:\n      - \"80:80\"\n      - \"443:443\"\n      - \"19322:19322/udp\"\n    volumes:\n      - /var/run/docker.sock:/tmp/docker.sock:ro\n```\n\nYou will have to add the hosts to `C:\\Windows\\System32\\drivers\\etc\\hosts` manually. There are various Powershell scripts available to help manage this:\n\n - http://get-carbon.org/Set-HostsEntry.html\n - https://gist.github.com/markembling/173887\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodekitchen%2Fdinghy-http-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodekitchen%2Fdinghy-http-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodekitchen%2Fdinghy-http-proxy/lists"}