Skip to content

🔒 การควบคุมการเข้าถึง

หลักการทำงาน

ระบบควบคุมการเข้าถึงมี 3 เลเยอร์:

┌─────────────────────────────────────┐
│ 1. Filesystem Permissions (Linux)   │ GID: 1008-1013 │
├─────────────────────────────────────┤
│ 2. Nextcloud Group Folders          │ Read-Only      │
├─────────────────────────────────────┤
│ 3. Nginx + Cloudflare               │ HTTPS only     │
└─────────────────────────────────────┘

Layer 1: Filesystem Permissions

DirectoryOwnerGroupModeACL
/data/Company/rootnas_admin2775other:r-x
00_Admin/rootnas_admin(1008)2775other:r-x
01_Accounting/rootnas_accounting(1009)2775other:r-x
02_Marketing/rootnas_marketing(1010)2775other:r-x
03_Video/rootnas_video(1011)2775other:r-x
04_AI_QCCAP/rootnas_ai(1012)2775other:r-x
05_Staff/rootnas_staff(1013)2775other:r-x
90_Archive/rootnas_admin(1008)2775other:r-x
99_Backup_Drop/rootnas_staff(1013)3770ACL: nas_admin+

คำสั่ง ACL

bash
# ดู ACL ของโฟลเดอร์
getfacl /data/Company/01_Accounting

# เพิ่มสิทธิ์ read สำหรับทุกคน (other)
sudo setfacl -m o::rX /data/Company/01_Accounting

# เพิ่มสิทธิ์ read สำหรับ group เฉพาะ
sudo setfacl -m g:nas_admin:rX /data/Company/99_Backup_Drop

Layer 2: Nextcloud Group Folders

Group Folders Config

การเข้าถึงถูกควบคุมผ่าน Group Folders App:

bash
# สร้าง Group Folder
sudo -u ccdev docker exec -u www-data nextcloud-app \
  php occ groupfolders:create "01_Accounting"

# กำหนดสิทธิ์ให้กลุ่ม (ID=2, Read-Only)
sudo -u ccdev docker exec -u www-data nextcloud-app \
  php occ groupfolders:group 2 nas_accounting

# ดู Group Folders ทั้งหมด
sudo -u ccdev docker exec -u www-data nextcloud-app \
  php occ groupfolders:list

Permissions Matrix

Folder IDFolder NameGroupsAccess
100_Adminnas_adminRead
201_Accountingnas_accountingRead
302_Marketingnas_marketingRead
403_Videonas_videoRead
504_AI_QCCAPnas_aiRead
605_Staffnas_staffRead
790_Archivenas_adminRead
899_Backup_Dropnas_staff, nas_adminRead

Layer 3: Network Security

Cloudflare

  • SSL/TLS encryption (Flexible mode)
  • DDoS protection
  • IP masking

Nginx

  • HTTP → 301 redirect to HTTPS (for direct access)
  • X-Forwarded-Proto: https header passthrough
  • Client max body size: 10 GB
  • Timeout: 300s

UFW Firewall

bash
sudo ufw status | grep -E '80|443'
# 80/tcp    ALLOW  Anywhere
# 443/tcp   ALLOW  Anywhere

การรักษาความปลอดภัยเพิ่มเติม (แนะนำ)

  1. 2FA: ติดตั้ง Two-Factor Authentication app
  2. IP Restriction: จำกัด IP ที่เข้าถึง Admin panel
  3. Audit Log: เปิดใช้งาน logging
bash
# ติดตั้ง 2FA
sudo -u ccdev docker exec -u www-data nextcloud-app \
  php occ app:install twofactor_totp

Nextcloud NAS Documentation