Docker deploys Nginx+FastDFS plug-in

1. Deploy FastDFS

1. Preparation

docker pull qinziteng/fastdfs:5.05
Pwd="/data/software/fastdfs"
mkdir ${Pwd}/{
    
    storage,tracker} -p

2. Create a TEST container and COPY the fastdfs directory locally to facilitate subsequent maintenance and management!

docker run -id --name fastdfs qinziteng/fastdfs:5.05
docker cp fastdfs:/home/fastdfs/conf /etc/fdfs
docker rm -f fastdfs

3. Run the FastDFS container
. Note: TRACKER_SERVERPlease replace the variable with the current server IP:22122! ! !

docker run -id --name fastdfs \
    -v ${Pwd}/storage:/home/fastdfs/storage \
    -v ${Pwd}/tracker:/home/fastdfs/tracker \
    -v /etc/localtime:/etc/localtime \
    -v /etc/fdfs:/home/fastdfs/conf \
    --restart=always \
     --net host \
     -e TRACKER_SERVER="16.32.15.115:22122" \
    qinziteng/fastdfs:5.05

2. Deploy Nginx (with FastDFS plug-in)

1. Preparation

docker pull qinziteng/nginx-fastdfs:v1
mkdir /usr/local/nginx/conf.d -p
mkdir var/log/nginx -p

2. Create nginx configuration file

cat > /usr/local/nginx/conf.d/nginx_fastdfs.conf << EOF
server {
    listen       80;
	server_name 127.0.0.1;


	location ^~ /group1/M00/ {
        alias /home/fastdfs/storage;
        ngx_fastdfs_module;
        charset 'utf-8';
	}

	location / {
       		root /usr/share/nginx/html;
        	index index.html;  
	}
}
EOF

3. Run Nginx container

  • Nginx container is based on FastDFS, so FastDFS must be deployed first
  • TRACKER_SERVERPlease keep the variables consistent with the above, that is, which FastDFS Nginx wants to connect to
docker run -itd --name nginx \
   -v ${Pwd}/storage:/home/fastdfs/storage \
   -v /etc/fdfs:/etc/fdfs \
   -v /var/log/nginx:/var/log/nginx \
   -v /etc/localtime:/etc/localtime \
   -v /usr/local/nginx:/usr/local/nginx \
   --restart=always \
   -e TRACKER_SERVER="16.32.15.115:22122"  \
   -p 80:80 qinziteng/nginx-fastdfs:v1

3. FastDFS upload file Nginx access verification

1. Enter the FastDFS container and upload the file

docker exec -it fastdfs /bin/bash
echo "已经 $(date +%F,%T)了,还不休息????" > six.txt
fdfs_upload_file /home/fastdfs/conf/client.conf six.txt

group1/M00/00/00/ECAPc2UPGw6AfPG6AAAAN9ApjR8324.txt

Insert image description here

Copy this and add it to the end of the nginx access path!

2. Nginx access verification
Browser access:http://IP/group1/M00/00/00/ECAPc2UPGw6AfPG6AAAAN9ApjR8324.txt
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_45310323/article/details/133223447