Cấu hình HTTP Basic Authentication trên WebServer Apache – httpd
Monday 06/09/2021
HTTP Basic Authentication là kiểu xác thực cơ bản nhất của một WebServer Apache yêu cầu client nhập username + password mỗi khi request. Client cần thêm header Authorization vào tất cả các request. Username và password không được encrypt mà được cấu trúc như sau:
nối username và password theo dạng: username:password
encode chuỗi trên với Base64
thêm từ khoá Basic
Để cấu hình HTTP Basic Authentication cho website trên máy chủ hoạt động với WebServer Apache – httpd, chúng ta thực hiện như sau:
Mục lục
1. Xác định file config/virtualhost
Trên máy chủ chạy WebServer Apache – httpd sử dụng command: httpd -S để xác định file config/virtualhost của website
2. Thiết lập password file
Sử dụng command htpasswd để thực hiện theo cấu trúc như sau:
htpasswd -c [/path/file/password] [user]
Với:
[/path/file/password]: là đường dẫn của file chứa username + password
[user]: là tên username để client đăng nhập
Ví dụ:
htpasswd -c /etc/httpd/conf/.htpasswd admin
3. Cấu hình HTTP Basic Authentication
Mở file config/virtualhost của website đã được xác định trước đó và thêm nội dung sau:
Nhập username + password đã tạo trước đó sẽ truy cập được website.
Mọi chi tiết khác cần hỗ trợ, vui lòng gửi yêu cầu về kythuat@pavietnam.vn hoặc hotline 19009477 ext: 2
Xem thêm các hướng dẫn khác liên quan đến VPS/Server tại đây.