My Quick Notes

Ain't Nobody Got Time to Read

nginx

1 bài viết

NGINX Basic Authentication

Gói yêu cầu

  • Trên Debian: apache2-utils.

    sudo apt-get install apache2-utils
  • Trên Fedora: httpd-tools.

    sudo dnf install httpd-tools

Tạo file lưu trữ user:password

Tạo file /etc/nginx/.htpasswd là file chứa thông tin về người dùng và mật khẩu.

sudo htpasswd -c /etc/nginx/.htpasswd user1

Tùy chọn -c chỉ nên dùng nếu file chưa tồn tại nếu không nó sẽ ghi đè file đã có. Để thêm người dùng khác, ta chạy lệnh giống như trên nhưng bỏ tùy chọn -c.

sudo htpasswd /etc/nginx/.htpasswd user2
Đọc tiếp...