Skip to content

PlusMagi's Blog By Pitt Phunsanit

Plus emotional magic to the knowledge of logic.

  • About’s Pitt
Close Button
PlusMagi's Blog By Pitt Phunsanit Network,Nginx NGINX: password

NGINX: password

2017-09-092017-09-09| phunsanitphunsanit| 0 Comment | 07:00
Categories:
  • Network
  • Nginx

สามารถตั้ง username, password ให้เว็บไซต์หรือโฟลเดอร์อย่าง phpMyAdmin ได้เหมือนกัน

  1. สร้าง password file .htpasswd ก่อนโดยจริง ๆ มันคือตัวเดียวกับของ Apache สามารถใช้ command
    sudo htpasswd -c /etc/phpmyadmin/.htpasswd {username}
    เหมือนกันสามารถอ่านวิธีสร้างไฟล์นี้ได้จาก Apache: password หรือ
    1. ไปที่ folder ที่เก็บไฟล์เว็บไซต์หรือโฟลเดอร์ที่ต้องการ เช่น
      cd /etc/phpmyadmin/
    2. สร้างไฟล์รหัสผ่านโดยใช้คำสั่ง
      sudo htpasswd -c .htpasswd {username} เช่น
      sudo htpasswd -c .htpasswd pitt_p
      ระบุรหัสผ่านและยืนยันรหัสผ่าน
    3. สร้าง user เพิ่มเติมโดยไม่มี -c เช่น
      sudo htpasswd .htpasswd pitt
      จนกว่าจะครบ
  2. ไปที่ nginx config เช่น
    cd /etc/nginx/sites-available
  3. เปิดไฟล์ config เว็บไซต์ที่ต้องการ เช่น
    sudo nano pitt.plusmagi.com.conf เพิ่ม
    ...
    server {
    ... location /phpmyadmin { auth_basic "Administrator’s Area"; auth_basic_user_file /etc/phpmyadmin/.htpasswd; }
    ...
    }
    ... 
    
  4. แล้ว save โดน CTRL + X และ Y
  5. เทสคอนฟิกเกอเรชั่นโดยใช้
    nginx -t
  6. รีสตาร์ทเอนจินเอกซ์ โดย
    sudo service nginx restart
  7. เข้า url ที่ต้องการ ควรจะมีการถามยูสเซอร์ พาสเวิร์ด

อ่านเพิ่มเติม

  • Apache: password
  • Restricting Access with HTTP Basic Authentication/
ป้ายกำกับ:Authentication, Download, Login, Password, Username

แนะแนวเรื่อง

PREVIOUS Previous post: เข้าเว็บโดนบล็อก เฟสบุ๊คได้ทั้งหมด ทุกเว็บ
NEXT Next post: MySQL: ERROR 1290 (HY000)Allow Remote Access

Projects

  • Statement Columns Mapping Helper
  • PlusMagi Site Search
  • jQuery Plus Repeater

Recent Posts

  • WordPress: ดูว่า post ทุก ๆ วันเสาร์ใช่มั๋ย
  • เทคนิคตั้งค่า umask 002 ให้กับทุก User บน Mac อัตโนมัติผ่าน Terminal (Batch Script)
  • TabulatorPlus: Deep Merge
  • Homebrew: แชร์กันหลาย User (Multi-User Setup)
  • TabulatorPlus: Universal Style

Archives

Categories

  • AI (25)
  • Businesses (28)
  • Design (56)
    • UX/UI (22)
  • Histories (16)
  • Life (118)
    • Books (51)
    • Cartoon (5)
    • Movies (10)
    • Sci-Fi (19)
    • Tips and Tricks (26)
    • พุทธ (7)
  • Network (139)
    • Apache HTTP Server (16)
    • IOT (1)
    • Nginx (30)
    • Stalwart (6)
  • Operating Systems (276)
    • Unix-like (202)
      • Android (16)
        • F-Droid (5)
      • Homebrew (21)
      • iPhone (8)
      • Linux (118)
      • macOS (100)
        • OrbStack (11)
      • Oh My ZSH (4)
      • Shell Script (38)
      • SSH (11)
    • Windows (119)
      • PowerShell (24)
      • WSL (25)
  • Programming (760)
    • .NET (19)
      • .NET Core EF (6)
      • C# (17)
    • API (26)
      • REST (5)
      • Swagger (6)
    • Database (185)
      • DBeaver (3)
      • MariaDB (31)
      • MySql (68)
      • Oracle Database (6)
        • 10g (3)
      • PostgreSQL (9)
      • RDBMS (2)
      • SQL Server (85)
        • SSMS (8)
        • T-SQL (26)
      • SQLite (1)
    • PowerBuilder (10)
    • Python (5)
    • Rust (4)
    • System Analyst (SA) (35)
    • Testing (21)
      • Automated Testing (12)
        • Playwright (6)
    • UML (7)
    • Web (389)
      • Backend (245)
        • Golang (1)
        • Java (47)
          • Spring Boot (14)
        • Node.js (2)
        • PHP (196)
          • Laravel (16)
          • Yii (5)
      • Frontend (134)
        • CSS (18)
          • Tailwind CSS (5)
        • JavaScript (121)
          • Angular (3)
          • jQuery (61)
          • Tabulator (19)
          • Vue.js (5)
      • WordPress (26)
  • Programs (97)
    • Excel (12)
  • SecDevOps (90)
    • CI/CD (5)
    • Docker (40)
    • GIT (31)
  • Security (66)
  • Uncategorized (3)
  • กฎหมาย (9)

Sirat WordPress Theme By VWThemes

Scroll Up
Go to mobile version