说明:凡以“#”开头的命令为可选
#armbian-software #software id:101
1.启用Docker对IPv6的支持
docker network inspect bridge
ip -6 route show #2409:8c00:de0:fad0::/64
vim /etc/docker/daemon.json #拷贝进如下内容
#########################################################################
{
"ipv6": true,
"fixed-cidr-v6": "2409:8c00:de0:fad0::/64", #用ip -6 route show获取的IPv6前缀替换
}
#########################################################################
systemctl reload docker && systemctl restart docker
#docker network inspect bridge
2.拉取nginx镜像并创建容器
docker pull nginx
docker run --name mynginx -p 10081:80 -d nginx
#curl 127.0.0.1:10081
3.配置mynginx容器、宿主机映射挂载配置文件和网页文件
mkdir -p /home/dockers/nginx/{html,conf,log}
docker cp mynginx:/etc/nginx/nginx.conf /home/dockers/nginx/conf
docker cp mynginx:/usr/share/nginx/html /home/dockers/nginx
docker cp mynginx:/var/log/nginx /home/dockers/nginx/log
docker stop mynginx
docker rm -f mynginx
#vim /home/dockers/nginx/conf/default.conf
vim /home/dockers/nginx/conf/nginx.conf
#修改nginx.conf配置文件,
#########################################################################
user nginx;
worker_processes auto;
events {
worker_connections 512;
}
http {
log_format '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server {
listen [::]:port1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://localhost:8096;
}
}
server {
listen [::]:port2;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://localhost:10085;
}
}
#include conf.d/default.conf
}
#########################################################################
docker run --name mynginx --net host \
-v /home/dockers/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /home/dockers/nginx/conf/default.conf:/etc/nginx/conf.d/default.conf \
-v /home/dockers/nginx/html:/usr/share/nginx/html \
-v /home/dockers/nginx/log:/var/log/nginx -d nginx
5.验证与调优
浏览器输入example.com:3388访问jelly服务,example.com:3399访问pandora服务。
(1)关注防火墙状态和放行情况
(2)建议修改DNS服务器上的A记录,由二级域名(如www)修改为@