I have several services running in Docker containers, all behind an an Nginx reverse proxy (using nginx-proxy/nginx-proxy
). All of the services run on different subdomains, and they are all working correctly with HTTPS etc.
I am now trying to host another container that uses Nginx to serve a static Web site on the domain itself, without a subdomain, but I am struggling to get it to work.
Here is my minimal docker-compose.yml
:
version: "3"
services:
example:
image: nginx
expose:
- 80
- 443
restart: unless-stopped
environment:
VIRTUAL_HOST: domain.tld
LETSENCRYPT_HOST: domain.tld
container_name: example
volumes:
- ./content:/usr/share/nginx/html
networks:
default:
external:
name: nginx-proxy
This does not work: it shows a 500 Internal Server Error whether I try to access it through HTTP or HTTPS. If I do the exact same thing but using subdomain.domain.tld
for the VIRTUAL_HOST
and LETSENCRYPT_HOST
environment variables, it works fine for both.
If I add the following to the docker-compose.yml
file:
ports:
- "8003:80"
- "8443:443"
...then I can access the site at http://domain.tld:8003
, but https://domain.tld:8443
shows a failure to connect and https://domain.tld
still shows a 500 error. http://domain.tld
redirects to https://domain.tld
.