I am currently serving static files through the nginx container and have set up a custom www.domain.com.conf file for it.
This is how it's set up
server {
server_name www.domain.com domain.com;
listen 80;
proxy_buffering off;
access_log /var/log/nginx/access.log;
location / {
root /app/dist/;
try_files $uri /index.html;
}
}
How do I configure let's encrypt to generate certificates for this domain?
I have tried running my containers using this
version: "2"
services:
backend:
image: backend
environment:
VIRTUAL_HOST: api.domain.com
VIRTUAL_PORT: 8080
LETSENCRYPT_HOST: api.domain.com
LETSENCRYPT_EMAIL: [email protected]
restart: always
proxy:
image: proxy-with-static
environment:
LETSENCRYPT_HOST: www.domain.com,domain.com
LETSENCRYPT_EMAIL: [email protected]
volumes:
- /etc/nginx/vhost.d
- /etc/nginx/certs:/etc/nginx/certs
- /usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
ports:
- "80:80"
- "443:443"
depends_on:
- backend
restart: always
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
volumes_from:
- proxy
restart: always
This set up is working with the backend container but it outputs an error for www.domain.com domain.
Note that the proxy image I am using is based on jwilder/nginx-proxy I just customized it so that I can copy my static files in that container and let it use the custom .conf
Any thought on this? Is the way I am serving my static files or my configuration for it not recommended?
I was able to come up a way for this. What I did was to have the static files served by a vanilla nginx on a different container and then I added VIRTUAL_HOST and LETSENCRYPT_HOST for it in the docker-compose file and everything worked as expected.
Most helpful comment
I was able to come up a way for this. What I did was to have the static files served by a vanilla nginx on a different container and then I added
VIRTUAL_HOSTandLETSENCRYPT_HOSTfor it in the docker-compose file and everything worked as expected.