大佬教程收集整理的这篇文章主要介绍了Docker+Nginx+Ssl,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
/soft/Nginx/conf
/soft/Nginx/conf/conf.d
/soft/Nginx/html
/soft/Nginx/log
/soft/Nginx/ssl //证书先放到这里
vim /soft/Nginx/conf/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/Nginx/log/host.access.log main;
location / {
root /usr/share/Nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/Nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.PHP$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.PHP$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.PHP;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with Nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
vim /soft/Nginx/conf/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 /etc/Nginx/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;
}
vim /soft/Nginx/html/index.html
<html>
<head>
<Meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>系统时间</title>
</head>
<body>
<div id="datetime">
<script>
setInterval("document.getElementById('datetime').innerHTML=new Date().toLocaleString();", 1000);
</script>
</div>
</body>
docker run -d \
-p 80:80 \
-v /soft/Nginx/html:/usr/share/Nginx/html \
-v /soft/Nginx/log:/usr/share/Nginx/log \
-v /soft/Nginx/conf/Nginx.conf:/etc/Nginx/Nginx.conf \
-v /soft/Nginx/conf/conf.d/default.conf:/etc/Nginx/conf.d/default.conf \
-v /etc/localtime:/etc/localtime:ro \
--name Nginx \
Nginx:1.10
-d: 后台运行容器,并返回容器ID;
-p: 指定端口映射,格式为:主机(宿主)端口:容器端口
-v: 挂载后的目录:原目录
--name: 为容器指定一个名称;
\:换行
docker cp /soft/Nginx/ssl/1_zhezhao.work_bundle.crt 723959a72914:/etc/Nginx/ssl
docker cp /soft/Nginx/ssl/2_zhezhao.work.key 723959a72914:/etc/Nginx/ssl
server {
listen 80 ssl;
server_name zhezhao.work;
#Nginx容器内证书地址
ssl_certificate /etc/Nginx/ssl/1_zhezhao.work_bundle.crt;
#Nginx容器内证书地址
ssl_certificate_key /etc/Nginx/ssl/2_zhezhao.work.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root /usr/share/Nginx/html;
index index.html index.htm;
}
location = /50x.html {
root /usr/share/Nginx/html;
}
}
server {
listen 443 ssl;
server_name zhezhao.work;
ssl_certificate /etc/Nginx/ssl/1_zhezhao.work_bundle.crt;
ssl_certificate_key /etc/Nginx/ssl/2_zhezhao.work.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
docker restart Nginx
以上是大佬教程为你收集整理的Docker+Nginx+Ssl全部内容,希望文章能够帮你解决Docker+Nginx+Ssl所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。