1、腾讯云申请SSL证书
2、下载证书及私钥文件
3、启动tomcat容器,映射webapps、logs
[root@wugenqiang ~]# docker run --name tomcat1 --rm -d -p 8080:8080 -v /projects/server/tomcat/webapps:/usr/local/tomcat/webapps -v /projects/server/tomcat/logs:/usr/local/tomcat/logs tomcat
4.启动nginx容器,指定证书、私钥、nginx.conf、logs,nginx.conf配置https相关以及tomcat转发
本地配置nginx.conf映射
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server
{
listen 80;
server_name <span style="color:#ff6666;">www.wugenqiang.club</span>;
rewrite ^(.*) https://$host$1 permanent;
}
server{
listen 443;
server_name <span style="color:#ff6666;">www.wugenqiang.club</span>;
ssl on;
ssl_certificate <span style="background-color:rgb(255,255,255);"><span style="color:#ff6666;">/key/server.crt</span></span>;
ssl_certificate_key <span style="color:#ff6666;">/key/private.key</span>;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass <span style="color:#ff6666;">http://127.0.0.1:8080/</span>;
}
error_log /logs/error_dev.log error;
access_log /logs/access_dev.log main;
}
}
启动nginx
docker run --name nginx --rm -v /projects/server/nginx/nginx.conf:/etc/nginx/nginx.conf -v /projects/server/nginx/certs:/key -v /projects/server/nginx/logs:/logs -d -p 80:80 -p 443:443 nginx