{"id":19167138,"url":"https://github.com/psmb/nginx-proxy","last_synced_at":"2026-03-01T10:35:12.666Z","repository":{"id":27898463,"uuid":"31390105","full_name":"psmb/nginx-proxy","owner":"psmb","description":"Reverse proxy for docker","archived":false,"fork":false,"pushed_at":"2015-03-03T15:11:09.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T23:25:54.482Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/psmb.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-02-26T21:37:08.000Z","updated_at":"2015-02-26T21:37:08.000Z","dependencies_parsed_at":"2022-09-04T08:51:01.889Z","dependency_job_id":null,"html_url":"https://github.com/psmb/nginx-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/psmb/nginx-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psmb%2Fnginx-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psmb%2Fnginx-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psmb%2Fnginx-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psmb%2Fnginx-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psmb","download_url":"https://codeload.github.com/psmb/nginx-proxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psmb%2Fnginx-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29966870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T09:33:09.965Z","status":"ssl_error","status_checked_at":"2026-03-01T09:25:48.915Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-09T09:35:57.050Z","updated_at":"2026-03-01T10:35:12.633Z","avatar_url":"https://github.com/psmb.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"![nginx 1.7.8](https://img.shields.io/badge/nginx-1.7.8-brightgreen.svg) ![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)\n\nnginx-proxy sets up a container running nginx and [docker-gen][1].  docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.\n\nSee [Automated Nginx Reverse Proxy for Docker][2] for why you might want to use this.\n\n### Usage\n\nTo run it:\n\n    $ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy\n\nThen start any containers you want proxied with an env var `VIRTUAL_HOST=subdomain.youdomain.com`\n\n    $ docker run -e VIRTUAL_HOST=foo.bar.com  ...\n\nProvided your DNS is setup to forward foo.bar.com to the a host running nginx-proxy, the request will be routed to a container with the VIRTUAL_HOST env var set.\n\n### Multiple Ports\n\nIf your container exposes multiple ports, nginx-proxy will default to the service running on port 80.  If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one.  If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected.\n\n  [1]: https://github.com/jwilder/docker-gen\n  [2]: http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/\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\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### SSL Backends\n\nIf you would like to connect to your backend using HTTPS instead of HTTP, set `VIRTUAL_PROTO=https` on the backend container.\n\n### Separate Containers\n\nnginx-proxy can also be run as two separate containers using the [jwilder/docker-gen](https://index.docker.io/u/jwilder/docker-gen/)\nimage and the official [nginx](https://registry.hub.docker.com/_/nginx/) image.\n\nYou may want to do this to prevent having the docker socket bound to a publicly exposed container service.\n\nTo run nginx proxy as a separate container you'll need to have [nginx.tmpl](https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl) on your host system.\n\nFirst start nginx with a volume:\n\n\n    $ docker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx\n\nThen start the docker-gen container with the shared volume and template:\n\n```\n$ docker run --volumes-from nginx \\\n    -v /var/run/docker.sock:/tmp/docker.sock \\\n    -v $(pwd):/etc/docker-gen/templates \\\n    -t docker-gen -notify-sighup nginx -watch -only-published /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf\n```\n\nFinally, start your containers with `VIRTUAL_HOST` environment variables.\n\n    $ docker run -e VIRTUAL_HOST=foo.bar.com  ...\n\n### SSL Support\n\nSSL is supported using single host, wildcard and SNI certificates using naming conventions for\ncertificates or optionally specifying a cert name (for SNI) as an environment variable.\n\nTo enable SSL:\n\n    $ docker run -d -p 80:80 -p 443:443 -v /path/to/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy\n\nThe contents of `/path/to/certs` should contain the certificates and private keys for any virtual\nhosts 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` should have a\n`foo.bar.com.crt` and `foo.bar.com.key` file in the certs directory.\n\n#### Wildcard Certificates\n\nWildcard certificates and keys should be name after the domain name with a `.crt` and `.key` extension.\nFor example `VIRTUAL_HOST=foo.bar.com` would use cert name `bar.com.crt` and `bar.com.key`.\n\n#### SNI\n\nIf your certificate(s) supports multiple domain names, you can start a container with `CERT_NAME=\u003cname\u003e`\nto identify the certificate to be used.  For example, a certificate for `*.foo.com` and `*.bar.com`\ncould be named `shared.crt` and `shared.key`.  A container running with `VIRTUAL_HOST=foo.bar.com`\nand `CERT_NAME=shared` will then use this shared cert.\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 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, a 503 will be returned.\n\nNote that in the latter case, a browser may get an connection error as no certificate is available\nto establish a connection.  A self-signed or generic cert named `default.crt` and `default.key`\nwill allow a client browser to make a SSL connection (likely w/ a warning) and subsequently receive\na 503.\n\n### Basic Authentication Support\n\nIn order to be able to securize your virtual host, you have to create a file named as its equivalent VIRTUAL_HOST variable on directory\n/etc/nginx/htpasswd/$VIRTUAL_HOST\n\n    $ docker run -d -p 80:80 -p 443:443 -v /path/to/htpasswd:/etc/nginx/htpasswd -v /path/to/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy\n\nYou'll need apache2-utils on the machine you plan to create de htpasswd file. Follow these [instructions](http://httpd.apache.org/docs/2.2/programs/htpasswd.html)\n\n### Custom Nginx Configuration\n\nIf you need to configure Nginx beyond what is possible using environment variables, you can provide custom configuration files on either a proxy-wide or per-`VIRTUAL_HOST` basis.\n\n#### Proxy-wide\n\nTo add settings on a proxy-wide basis, add your configuration file under `/etc/nginx/conf.d` using a name ending in `.conf`.\n\nThis can be done in a derived image by creating the file in a `RUN` command or by `COPY`ing the file into `conf.d`:\n\n```Dockerfile\nFROM jwilder/nginx-proxy\nRUN { \\\n      echo 'server_tokens off;'; \\\n      echo 'client_max_body_size 100m;'; \\\n    } \u003e /etc/nginx/conf.d/my_proxy.conf\n```\n\nOr it can be done by mounting in your custom configuration in your `docker run` command:\n\n    $ docker run -d -p 80:80 -p 443:443 -v /path/to/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy\n\n#### Per-VIRTUAL_HOST\n\nTo add settings on a per-`VIRTUAL_HOST` basis, add your configuration file under `/etc/nginx/vhost.d`. Unlike in the proxy-wide case, which allows mutliple config files with any name ending in `.conf`, the per-`VIRTUAL_HOST` file must be named exactly after the `VIRTUAL_HOST`.\n\nIn order to allow virtual hosts to be dynamically configured as backends are added and removed, it makes the most sense to mount an external directory as `/etc/nginx/vhost.d` as opposed to using derived images or mounting individual configuration files.\n\nFor example, if you have a virtual host named `app.example.com`, you could provide a custom configuration for that host as follows:\n\n    $ docker run -d -p 80:80 -p 443:443 -v /path/to/vhost.d:/etc/nginx/vhost.d:ro -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy\n    $ { echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } \u003e /path/to/vhost.d/app.example.com\n\nIf you are using multiple hostnames for a single container (e.g. `VIRTUAL_HOST=example.com,www.example.com`), the virtual host configuration file must exist for each hostname. If you would like to use the same configuration for multiple virtual host names, you can use a symlink:\n\n    $ { echo 'server_tokens off;'; echo 'client_max_body_size 100m;'; } \u003e /path/to/vhost.d/www.example.com\n    $ ln -s www.example.com /path/to/vhost.d/example.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsmb%2Fnginx-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsmb%2Fnginx-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsmb%2Fnginx-proxy/lists"}