Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Automated nginx proxy for Docker containers using docker-gen

License

NotificationsYou must be signed in to change notification settings

nginx-proxy/nginx-proxy

Repository files navigation

TestGitHub releasenginx 1.27.5Docker Image SizeDocker starsDocker pulls

nginx-proxy sets up a container running nginx anddocker-gen. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.

SeeAutomated Nginx Reverse Proxy for Docker for why you might want to use this.

Usage

To run it:

docker run --detach \    --name nginx-proxy \    --publish 80:80 \    --volume /var/run/docker.sock:/tmp/docker.sock:ro \    nginxproxy/nginx-proxy:1.7

Then start any containers (here an nginx container) you want proxied with an env varVIRTUAL_HOST=subdomain.yourdomain.com

docker run --detach \    --name your-proxied-app \    --env VIRTUAL_HOST=foo.bar.com \    nginx

Provided your DNS is setup to resolvefoo.bar.com to the host running nginx-proxy, a request tohttp://foo.bar.com will then be routed to a container with theVIRTUAL_HOST env var set tofoo.bar.com (in this case, theyour-proxied-app container).

The containers being proxied must :

  • expose the port to be proxied, either by using theEXPOSE directive in theirDockerfile or by using the--expose flag todocker run ordocker create.
  • share at least one Docker network with the nginx-proxy container: by default, if you don't pass the--net flag when your nginx-proxy container is created, it will only be attached to the default bridge network. This means that it will not be able to connect to containers on networks other than bridge.

Note: providing a port number inVIRTUAL_HOST isn't suported, please seevirtual ports orcustom external HTTP/HTTPS ports depending on what you want to achieve.

Image variants

The nginx-proxy images are available in two flavors.

Debian based version

This image is based on the nginx:mainline image, itself based on the debian slim image.

docker pull nginxproxy/nginx-proxy:1.7

Alpine based version (-alpine suffix)

This image is based on the nginx:alpine image.

docker pull nginxproxy/nginx-proxy:1.7-alpine

Important

A note onlatest andalpine:

It is not recommended to use thelatest (nginxproxy/nginx-proxy,nginxproxy/nginx-proxy:latest) oralpine (nginxproxy/nginx-proxy:alpine) tag for production setups.

Those tags point to the latest commit in themain branch. They do not carry any promise of stability, and using them will probably put your nginx-proxy setup at risk of experiencing uncontrolled updates to non backward compatible versions (or versions with breaking changes). You should always specify the version you want to use explicitly to ensure your setup doesn't break when the image is updated.

Additional documentation

Please check thedocs section.

Powered by

GoLand logoPyCharm logo

About

Automated nginx proxy for Docker containers using docker-gen

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages


[8]ページ先頭

©2009-2025 Movatter.jp