I have a website running at https://domain.com and IP a.a.a.a, with an SSL cert issued by GoDaddy. The server is deployed with Nginx. Everything is working fine as it is.
However I'm trying to deploy the same website with Docker in a new server with IP b.b.b.b, so I did the following:
- Pull nginx image from Docker
- Copy the domain.com.chained.crt and domain.com.key files from server a.a.a.a to server b.b.b.b
- In the Docker file, I copy the cert files to the image
- When I run the container and check nginx with
nginx -t
, it seems to be working fine. - Ports 443 and 80 are open for external requests
- I check that the website is running by accessing to b.b.b.b:80 from an external client
- Configure the DNS to resolve to b.b.b.b instead of a.a.a.a
- Check that http://domain.com is working
Up to that point everything is working fine. But when I try to access https://domain.com I get the following errors:
- With firefox: ERR_SSL_PROTOCOL_ERROR
- With chrome: SSL_ERROR_RX_RECORD_TOO_LONG
- The site https://www.sslshopper.com/ssl-checker.html tells me this:
No SSL certificates were found on domain.com. Make sure that the name resolves to the correct server and that the SSL port (default is 443) is open on your server's firewall.
The Nginx error logs don't tell me much, although I have them in debug mode.
My main question is: Can I copy the cert files from one server to another or do I have to generate them again?
Edit: This is the docker-compose.yml
sevices:
nginx:
build: ./nginx
image: nginx
ports:
- "80:80"
- "443:443"
redis:
image: redis
ports:
- "6379:6379"
mongo:
image: mongo
ports:
- "27017:27017"
volumes:
- /var/mongodata:/data/db
Dockerfile
FROM custom:latest
COPY nginx.conf /etc/nginx/nginx.conf
COPY /ssl/domain.com.key /etc/nginx/ssl/domain.com.key
COPY /ssl/domain.com.chained.crt /etc/nginx/ssl/domain.com.chained.crt
RUN apt-get -y install nodejs libssl1.0-dev nodejs-dev node-gyp npm
[...]
CMD ["nginx", "-g", "daemon off;"]
nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
server {
listen 80;
listen [::]:80;
listen 443;
server_name www.domain.com;
ssl_certificate /etc/nginx/ssl/domain.com.chained.crt;
ssl_certificate_key /etc/nginx/ssl/domain.com.key;
location / {
root /domain.com/;
try_files $uri$args $uri$args/ /index.html;
}
}
}