Build a WebDAV server with NGINX

Introduction

  1. Configure a WebDAV Server with NGINX
  2. User cloud access specified folder after login



Environment

GCP Instance
Ubuntu 18.04
NGINX
Root




Install

apt-get install nginx-full



Turn on gzip

Bandwidth is limited, and the performance of machines is always faster, so we compress data with gzip before sending them to customer to decrease the amount of traffic

sed -i '/gzip_/ s/#\ //g' /etc/nginx/nginx.conf

/gzip_/: Look for lines containing gzip_
s/#\ //g: Replace # with

It means that we uncomment the gzip




Configure WebDAV Server

Create config file

vim /etc/nginx/conf.d/webdav.conf

Config

server {
listen 80;
listen [::]:80;

server_name yourDomain;

auth_basic realm_name;
# The file containing authorized users
auth_basic_user_file /etc/nginx/.credentials.list;

# dav allowed method
dav_methods PUT DELETE MKCOL COPY MOVE;
# Allow current scope perform specified DAV method
dav_ext_methods PROPFIND OPTIONS;

# In this folder, newly created folder or file is to have specified permission. If none is given, default is user:rw. If all or group permission is specified, user could be skipped
dav_access user:rw group:rw all:r;

# Temporary folder
client_body_temp_path /tmp/nginx/client-bodies;

# MAX size of uploaded file, 0 mean unlimited
client_max_body_size 0;

# Allow autocreate folder here if necessary
create_full_put_path on;
}



Create users

  • 輸入 user
    echo -n 'userName:' | sudo tee -a /etc/nginx/.credentials.list; 
    Print out the user name, tee will print the user and direct it into /etc/nginx/.credential.list file

  • Enter password
    openssl passwd -apr1 | sudo tee -a /etc/nginx/.credentials.list;
    Turn password to encrypted characters with openssl passwd -apr1 rule, print and direct into /etc/nginx/.credentials.list file. -a = append



It’s done!

Learning note of TypeScript Google Cloud Pub/Sub:Qwik Start - Command Line

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×