Deploy Zdir Directory Listing Program with Docker

docker zdirzdir directory listingdeploy zdir dockerzdir installationnginx reverse proxy zdir
Published·Modified·

Zdir is a directory listing program developed in PHP that requires no database, offering simple installation and ease of use. It now supports deployment via Docker.

Manual Docker Deployment (Requires Basic Operations Knowledge)

Install Docker

Please ensure Docker is installed. If not, refer to: Linux Install Docker and Common Docker Commands.

Deploy Zdir with Docker

Run the following commands to create a user and group, and set directory permissions:

# Create user and group
groupadd www
useradd -M -g www www -s /sbin/nologin
# Set directory permissions
chown -R www:www /data/wwwroot/zdir

Copy and run the following command in the Docker container to start Zdir:

docker run --name="zdir"  \
    -d -p 1080:80 --restart=always \
    -v /data/wwwroot/default:/data/wwwroot/default \
    helloz/zdir \
    /usr/sbin/run.sh

After installation, visit http://IP:1080 and follow the on-screen prompts to complete the setup. The parameters below can be modified as needed:

  • 1080: The port the server listens on (Zdir access port).
  • /data/wwwroot/default: The Zdir installation path.
  • Default username: zdir, password: xiaoz.me.

Note:

If the command runs without errors but port 1080 is inaccessible, check if the firewall or security group allows traffic on port 1080:

# Allow port 1080 via firewalld
firewall-cmd --zone=public --add-port=1080/tcp --permanent
firewall-cmd --reload

One-Click Installation Script

If the steps above seem too complex, you can use the Docker for Zdir script provided by xiaoz for one-click installation, which significantly simplifies the process.

bash <(curl -Lsk https://raw.githubusercontent.com/helloxz/docker-zdir/master/zdir-install.sh)

Follow the script prompts to complete the setup. The content after successful installation is shown below:

Nginx Reverse Proxy

If you have Nginx installed on your server and wish to access Zdir via a domain name, configure a reverse proxy as follows:

server
    {
    listen          80;
    server_name     zdir.xiaoz.me;
    location / {
       proxy_pass http://127.0.0.1:1080;
       proxy_redirect off;
       proxy_set_header Host $host;
       client_max_body_size 50m;
           client_body_buffer_size 256k;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_max_temp_file_size 200m;
  }


location ~ .*(js|css|woff|woff2|gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)?$ {
       proxy_pass http://127.0.0.1:1080;
       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;
       expires 7d;
        access_log off;
  }

}

zdir.xiaoz.me should be replaced with your own domain name. Remember to restart Nginx after configuration to apply changes.

Get the Donor Version

Scan the QR code below to donate more than 30 yuan. Donors receive initial technical support and an ad-free version. After donating, please contact me via QQ: 337003006 to obtain the donor version.

Other Resources