Hi
I’m trying to add letsencrypt cert to nginx server.
NOTE: I’m using Docker containers for both Nginx server and my website
I get this error
The server could not connect to the client to verify the domain :: dns :: DNS problem: NXDOMAIN looking up A for www.example.com
while the container logs don’t show any error.
I create the key and cert using this command
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout privkey.pem -out fullchain.pem
What’s I’m missing?
here is my docker file for nginx:
FROM ubuntu:latest
RUN \
apt-get update && \
apt-get install -y nginx && \
rm -rf /var/lib/apt/lists/* && \
echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \
chown -R www-data:www-data /var/lib/nginx
VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx"]
COPY default.conf /etc/nginx/sites-available/default
RUN mkdir /etc/letsencrypt/
RUN mkdir /etc/letsencrypt/live/
RUN mkdir /etc/letsencrypt/live/example.com/
COPY fullchain.pem /etc/letsencrypt/live/example.com/fullchain.pem
COPY privkey.pem /etc/letsencrypt/live/example.com/privkey.pem
WORKDIR /etc/nginx
CMD ["nginx"]
EXPOSE 80
EXPOSE 443
and my nginx default.conf
server {
listen *:80;
server_name example.com;
access_log off;
rewrite ^/(.*) https://$server_name/$1;
}
server {
listen *:443 ssl default_server;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl on;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://example.com:3000/;
proxy_redirect off;
}
}