Publish: 2020-05-05 | Modify: 2020-06-21
Zdir is a directory listing program developed using PHP. It doesn't require a database and is easy to install and use. It now supports Docker deployment.
Install Docker
Please make sure you have Docker installed. If you haven't installed it yet, you can refer to: Linux Docker Installation and Common Commands
Deploy Zdir with Docker
Enter the following command to create a user and user group, and set directory permissions.
# Create user and user group
groupadd www
useradd -M -g www www -s /sbin/nologin
# Set directory permissions
chown -R www:www /data/wwwroot/zdir
Copy the following command to run Zdir in a Docker container.
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, access http://IP:1080
and follow the instructions on the page to complete the operation. You can modify the following parameters.
1080
: The port the server listens on, i.e., the Zdir access port/data/wwwroot/default
: Zdir pathzdir
, password: xiaoz.me
Note:
If there are no errors during the run, but you cannot access 1080
, check whether the firewall or security group allows access to port 1080
:
# Open port 1080 in firewalld
firewall-cmd --zone=public --add-port=1080/tcp --permanent
firewall-cmd --reload
If you find the above steps too complicated, you can use the Docker for Zdir script provided by Xiaoz for one-click installation, greatly simplifying the operation steps.
bash <(curl -Lsk https://raw.githubusercontent.com/helloxz/docker-zdir/master/zdir-install.sh)
Follow the prompts in the script to complete the installation. After successful installation, you will see the following content:
If you have Nginx installed on your server and want to access it through a domain name, you can configure reverse proxy access. The configuration is 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
is your own domain name for access. After configuring it, remember to restart Nginx for the changes to take effect.
Scan the QR code below. Donations of more than 30 yuan
can get the donor version, which includes initial technical support and ad removal. After making a donation, please contact me via QQ: 337003006 to get it.
I come from China and I am a freelancer. I specialize in Linux operations, PHP, Golang, and front-end development. I have developed open-source projects such as Zdir, ImgURL, CCAA, and OneNav.