---
title: "Bảo mật với Authelia 2FA: Hướng dẫn cài đặt và kích hoạt quy tắc bảo vệ chuẩn production"
description: "Hướng dẫn triển khai Authelia 2FA bằng Docker Compose kết hợp Nginx auth_request để bảo vệ mọi dashboard nội bộ (Jenkins, Grafana, Qdrant) trên VPS."
canonical: "https://thuecloud.vn/bao-mat-voi-authelia-2fa-huong-dan-cai-dat-va-kich-hoat-quy-tac-bao-ve-chuan-production"
markdown_url: "https://thuecloud.vn/bao-mat-voi-authelia-2fa-huong-dan-cai-dat-va-kich-hoat-quy-tac-bao-ve-chuan-production.md"
locale: "vi"
kind: "article"
published_at: "2026-11-22T16:18:13.436Z"
updated_at: "2026-11-22T16:18:12.867Z"
site: "ThueCloud.Vn"
estimated_tokens: 1819
---
# Bảo mật với Authelia 2FA: Hướng dẫn cài đặt và kích hoạt quy tắc bảo vệ chuẩn production

> Hướng dẫn triển khai Authelia 2FA bằng Docker Compose kết hợp Nginx auth_request để bảo vệ mọi dashboard nội bộ (Jenkins, Grafana, Qdrant) trên VPS.

- Canonical HTML: https://thuecloud.vn/bao-mat-voi-authelia-2fa-huong-dan-cai-dat-va-kich-hoat-quy-tac-bao-ve-chuan-production
- Markdown URL: https://thuecloud.vn/bao-mat-voi-authelia-2fa-huong-dan-cai-dat-va-kich-hoat-quy-tac-bao-ve-chuan-production.md
- Organization: ThueCloud.Vn
- Support Email: support@thuecloud.vn
- Hotline: 03333 499 48
- Published: 2026-11-22
- Updated: 2026-11-22

## Mục lục

- Cấu hình configuration.yml chuẩn production cho Authelia
- Tích hợp Authelia với Nginx Reverse Proxy
  - Bảng phân loại chính sách access_control khuyên dùng
- Câu hỏi thường gặp (FAQ)
  - Authelia tốn bao nhiêu RAM khi chạy kèm Nginx trên VPS?
  - Có thể tạo mật khẩu băm (Argon2id) cho file users_database.yml bằng lệnh nào?
  - Nếu dùng Redis làm storage cho session Authelia bị tắt đột ngột thì sao?

Nhiều công cụ quản trị mạnh mẽ như Grafana, Qdrant Dashboard, Portainer hay Bull Board mặc định không có sẵn xác thực hai lớp (2FA) hoặc quản lý user rất sơ sài. Thay vì mở từng cổng ra Internet với Basic Auth yếu ớt, triển khai **Authelia** trên [VPS Việt Nam](https://thuecloud.vn/vps-viet-nam) giúp bạn dựng một cổng đăng nhập SSO + 2FA (TOTP Google Authenticator / WebAuthn) đứng chắn trước toàn bộ các ứng dụng qua Nginx.

> **Tóm tắt nhanh (TL;DR):**
> - Triển khai Authelia qua Docker Compose kèm Redis để lưu session đăng nhập ổn định.
> - Cấu hình `access_control` phân chia rõ `one_factor`, `two_factor` và `bypass` (cho webhook/API công khai).
> - Tích hợp vào Nginx bằng chỉ thị `auth_request /internal/authelia/authz`.
> - *Cập nhật: 11/2026*

## Cấu hình `configuration.yml` chuẩn production cho Authelia

Trong tệp cấu hình `/opt/authelia/config/configuration.yml`, thiết lập chính sách `two_factor` mặc định cho mọi tên miền quản trị nội bộ và bật cơ chế tự động khóa khi đăng nhập sai nhiều lần (`regulation`):

```yaml
theme: dark
server:
  address: 'tcp://:9091/'

authentication_backend:
  file:
    path: /config/users_database.yml

regulation:
  max_retries: 5
  find_time: 5m
  ban_time: 15m

access_control:
  default_policy: deny
  rules:
    - domain: 'auth.example.com'
      policy: bypass
    - domain: '*.internal.example.com'
      policy: two_factor

session:
  cookies:
    - domain: 'example.com'
      authelia_url: 'https://auth.example.com'
      expiration: 1h
      inactivity: 15m
```

## Tích hợp Authelia với Nginx Reverse Proxy

Trong vhost Nginx của dịch vụ cần bảo vệ (ví dụ `grafana.internal.example.com`), thêm `auth_request` trỏ về container Authelia đang lắng nghe ở `127.0.0.1:9091`:

```nginx
location /internal/authelia/authz {
    internal;
    proxy_pass http://127.0.0.1:9091/api/authz/auth-request;
    proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
    proxy_set_header X-Forwarded-Method $request_method;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-URI $request_uri;
    proxy_set_header Content-Length "";
    proxy_pass_request_body off;
}

location / {
    auth_request /internal/authelia/authz;
    error_page 401 =302 https://auth.example.com/?rd=$scheme://$http_host$request_uri;
    proxy_pass http://127.0.0.1:3000;
}
```

### Bảng phân loại chính sách `access_control` khuyên dùng

| Policy Authelia | Mức bảo mật | Áp dụng cho |
|---|---|---|
| `two_factor` | Cao nhất (Mật khẩu + OTP/Passkey) | Portainer, Jenkins, Qdrant UI, Admin Panel |
| `one_factor` | Trung bình (Chỉ mật khẩu) | Tài liệu nội bộ ít nhạy cảm |
| `bypass` | Cho qua không cần đăng nhập | Endpoint `/health`, Webhook Telegram/Zalo |

Kết hợp Authelia với [so sánh chi phí chạy Crawler trên VPS Việt Nam](https://thuecloud.vn/so-sanh-chi-phi-chay-crawler-playwright-puppeteer-tren-vps-viet-nam-vs-aws-lightsail-va-digitalocean), [thêm Addon Domain và SSL Wildcard trên CloudPanel](https://thuecloud.vn/cloudpanel-tren-vps-cach-them-addon-domain-subdomain-va-ssl-wildcard) và [xử lý sự cố Qdrant Vector DB](https://thuecloud.vn/qdrant-vector-db-huong-dan-xu-ly-loi-timeout-oom-va-su-co-ket-noi-thuc-te). Xem thêm [giải pháp bảo mật](https://thuecloud.vn/giai-phap) và [FAQ](https://thuecloud.vn/faq).

> **Bảo vệ hệ thống doanh nghiệp chuẩn 2FA tại ThueCloud.Vn:**
> **KVM Enterprise NVMe** tại `vn-hn` (VAT `0%`, SLA `99,9%`, hoàn tiền `07 ngày`). **VPS VN 1** (`45.000đ`–`60.000đ`), **VPS VN 2** (`78.000đ`–`90.000đ`), **VPS VN 3** (`139.000đ`–`170.000đ/tháng`). Xem chi tiết tại [bảng giá](https://thuecloud.vn/pricing).

## Câu hỏi thường gặp (FAQ)

### Authelia tốn bao nhiêu RAM khi chạy kèm Nginx trên VPS?
Authelia viết bằng Go nên rất nhẹ, chỉ tiêu tốn khoảng 30–60 MB RAM ở trạng thái bình thường, hoàn toàn chạy mượt trên gói VPS VN 1.

### Có thể tạo mật khẩu băm (Argon2id) cho file `users_database.yml` bằng lệnh nào?
Bạn chạy lệnh `docker run --rm authelia/authelia:latest authelia crypto hash generate argon2 --password 'MatKhauCuaBan'` để sinh chuỗi hash an toàn.

### Nếu dùng Redis làm storage cho session Authelia bị tắt đột ngột thì sao?
Người dùng sẽ cần đăng nhập lại phiên mới; dữ liệu cấu hình tài khoản và khóa 2FA TOTP của người dùng vẫn được lưu an toàn trong file/SQLite/PostgreSQL backend nên không bị mất.

## References / Sources

- https://www.authelia.com/integration/proxies/nginx/
- https://www.authelia.com/configuration/security/access-control/

---

## Navigation & Machine-Readable Endpoints

- [Site Summary (llms.txt)](https://thuecloud.vn/llms.txt)
- [Full Technical Reference (llms-full.txt)](https://thuecloud.vn/llms-full.txt)
- [Pricing Catalog (Markdown)](https://thuecloud.vn/pricing.md)
- [Blog & Technical Guides (Markdown)](https://thuecloud.vn/blog.md)
- [XML Sitemap](https://thuecloud.vn/sitemap.xml)
