Hello my name's Rene from Mexico City,
I would like to have multiple domains in the same IP, like a VPS with docker.
In this moment I have tree domains which are: bar.com, foo.com and like.org
My main site is bar.com.
Only at bar.com do I have a let's encrypt certificate, the foo.com and like.org redirect is for bar.com certificate, when you open foo.com the browser says: "Your connection is not secure" if I add an exception the certificate shown is for bar.com
Thanks in advance
My configuration in docker-compose
version: "2"
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- /var/www/vhost.d:/etc/nginx/vhost.d
- /var/www/certs:/etc/nginx/certs:ro
- /usr/share/nginx/html
proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
restart: always
volumes:
- /var/www/certs:/etc/nginx/certs:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
volumes_from:
- nginx-proxy
networks:
default:
external:
name: nginx-proxy
The configuration of the domains is
version: '2'
services:
DEMO-DB1:
image: mariadb:latest
volumes:
- ./database/:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: example
MYSQL_USER: exampleusar
MYSQL_PASSWORD: examplexy
DEMO-WP1:
depends_on:
- DEMO-DB1
image: wordpress
restart: always
environment:
VIRTUAL_HOST: bar.com
VIRTUAL_PORT: 8001
VIRTUAL_PORT: 8002
LETSENCRYPT_HOST: bar.com, www.foo.com
LETSENCRYPT_EMAIL: [email protected]
WORDPRESS_DB_HOST: DEMO-DB1:3306
WORDPRESS_DB_NAME: dbuser ,
WORDPRESS_DB_USER: datauser
WORDPRESS_DB_PASSWORD: example
volumes:
- ./html:/var/www/html
- ./php.ini:/usr/local/etc/php/conf.d/uploads.ini
networks:
default:
external:
name: `nginx-proxy`
My second and third domain are the same on bar.com Docker Compose files, only difference is the VIRTUAL PORT variable
The domains are independent and work good, the problem is only with the certificate.
Sorry that's not readable, could you try using mardown's "insert code" button to have your compose files displayed properly ?
@buchdag Ok.
Thanks for your time
Let say you have those domains and subdomains all pointing to your host's IP:
If you have only one service running on your host's docker and you want all those domains/subdomains proxyed to the same container with SSL for all of them you'll have to do something this:
[...]
services:
[...]
your_proxyed_service:
[...]
environment:
VIRTUAL_HOST: bar.com, www.bar.com, foo.com, www.foo.com
VIRTUAL_PORT: XXXX
LETSENCRYPT_HOST: bar.com, www.bar.com, foo.com, www.foo.com
LETSENCRYPT_EMAIL: [email protected]
[...]
Every domain and subdomain that you want to be proxyed to the container must be explicitely declared in the VIRTUAL_HOST variable. Wether there is a redirect or not at the DNS level is an entirely different thing.
The same goes for the LETSENCRYPT_HOST variable.
The VIRTUAL_PORTmust be declared only once for each proxyed container and set to a single port you know to be exposed by the container.
Thanks for the support, only i have one nginx-proxy and one proxy-companion and i have a service for each site, so I need a DNS for this, do you know a project for this?
Thanks in advance
Hi,
Thanks for your support, in this tread:
https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion/issues/187
I remove the space caracteres and works!
This is my Docker-compose file for each site:
version: '2'
services:
EW-DB1:
image: mariadb:latest
volumes:
- ./database/:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: someone
MYSQL_DATABASE: data
MYSQL_USER: userex
MYSQL_PASSWORD: example0
EW-WP1:
depends_on:
- EW-DB1
image: wordpress
restart: always
environment:
VIRTUAL_HOST: foo.com, www.foo.com
VIRTUAL_PORT: 8002
LETSENCRYPT_HOST: bar.com,foo.com,www.foo.com
LETSENCRYPT_EMAIL: [email protected]
WORDPRESS_DB_HOST: EW-DB1:3306
WORDPRESS_DB_NAME: database
WORDPRESS_DB_USER: username
WORDPRESS_DB_PASSWORD: example
volumes: # this is where we tell Docker what to pay attention to
- ./html:/var/www/html
- ./php.ini:/usr/local/etc/php/conf.d/uploads.ini
networks:
default:
external:
name: nginx-proxy
Thanks for your suppor.
Most helpful comment
Let say you have those domains and subdomains all pointing to your host's IP:
If you have only one service running on your host's docker and you want all those domains/subdomains proxyed to the same container with SSL for all of them you'll have to do something this:
Every domain and subdomain that you want to be proxyed to the container must be explicitely declared in the
VIRTUAL_HOSTvariable. Wether there is a redirect or not at the DNS level is an entirely different thing.The same goes for the
LETSENCRYPT_HOSTvariable.The
VIRTUAL_PORTmust be declared only once for each proxyed container and set to a single port you know to be exposed by the container.