Operations 13 min read

Step-by-Step Guide to Building a FastDFS Cluster with Nginx and cpolar for Remote Access

This tutorial walks you through installing FastDFS, configuring its tracker and storage nodes, integrating it with Nginx, and exposing the service to the internet using cpolar, enabling remote file upload and download over a LAN and public network.

Open Source Linux
Open Source Linux
Open Source Linux
Step-by-Step Guide to Building a FastDFS Cluster with Nginx and cpolar for Remote Access

Introduction

FastDFS is an open‑source lightweight distributed file system that manages file storage, synchronization, and access (upload/download), addressing large‑capacity storage and load‑balancing needs, making it ideal for photo or video services.

1. Local FastDFS Setup

1.1 Environment Installation

Install required packages: yum -y install gcc-c++ Install libevent dependency:

yum -y install libevent

1.2 Install libfastcommon

Download libfastcommon, extract, compile and install:

cd /usr/local<br/>tar -zxvf libfastcommonV1.0.7.tar.gz<br/>cd libfastcommon-1.0.7/<br/>./make.sh<br/>./make.sh install

Copy the shared library to /usr/lib:

cp /usr/lib64/libfastcommon.so /usr/lib/

1.3 Install FastDFS

Download FastDFS, extract, compile and install:

cd /usr/local<br/>tar -zxvf FastDFS_v5.05.tar.gz<br/>cd FastDFS<br/>./make.sh<br/>./make.sh install

Copy configuration files:

cp -r conf/* /etc/fdfs/

1.4 Configure Tracker

Edit /etc/fdfs/tracker.conf and set base_path=/home/fastdfs. Create the directory and start the tracker:

mkdir /home/fastdfs<br>/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

Add the start command to /etc/rc.d/rc.local for auto‑start.

1.5 Configure Storage

Edit /etc/fdfs/storage.conf to set:

base_path=/home/fastdfs<br/>store_path0=/home/fastdfs/fdfs_storage<br/>tracker_server=YOUR_LAN_IP:22122

Create the storage directory and start the storage daemon:

mkdir /home/fastdfs/fdfs_storage<br>/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

Add the command to /etc/rc.d/rc.local for auto‑start.

1.6 Test Upload/Download

Use the test client to upload a file:

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /usr/local/test23.png

Modify /etc/fdfs/client.conf to match the tracker address.

1.7 Integrate with Nginx

Download the FastDFS Nginx module, extract and compile Nginx with the module:

cd /usr/local<br/>tar -zxvf fastdfs-nginx-module_v1.16.tar.gz<br/>cd fastdfs-nginx-module/src<br/>vim config   # replace /usr/local paths with /usr<br>cp mod_fastdfs.conf /etc/fdfs/

# Install Nginx dependencies
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
# Download and extract Nginx source
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar -zxvf nginx-1.16.1.tar.gz && cd nginx-1.16.1
# Configure with FastDFS module
./configure \
  --prefix=/usr/local/nginx \
  --add-module=/usr/local/fastdfs-nginx-module/src
make
make install

1.8 Configure Nginx

Add a server block to /usr/local/nginx/conf/nginx.conf:

server {
    listen 8089;
    server_name 192.168.59.133;
    location /group1/M00/ {
        ngx_fastdfs_module;
    }
}

Start Nginx: /usr/local/nginx/sbin/nginx If the PID file is missing, create the directory:

mkdir /var/run/nginx

2. LAN Test Access

Upload a test image and access it via the Nginx URL to verify the setup.

3. Install cpolar for Internet Exposure

Install cpolar:

curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash

Authenticate with your token: cpolar authtoken YOUR_TOKEN Enable and start the service:

sudo systemctl enable cpolar
sudo systemctl start cpolar

4. Configure Public Address

Create an HTTP tunnel pointing to Nginx port 8089 in the cpolar web UI, then obtain the public URL.

5. Fix Public Address (Reserve Subdomain)

Reserve a subdomain (e.g., fasttest) in the cpolar dashboard, edit the tunnel to use this subdomain, and update the tunnel.

6. Test Fixed Subdomain Access

Visit the reserved subdomain URL with the resource path to confirm remote access without a public IP.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxDistributed File SystemFastDFScpolar
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.