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, Network, Password, PHP, Security, 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

  • AI:thClaws
  • Laravel: php artisan tinker
  • Line: API มันทำอะไรได้บ้าง
  • Laravel: reset password
  • AWS S3 คืออะไร ? คู่มือครบจบสำหรับผู้เริ่มต้น

Archives

Categories

  • AI (10)
  • Businesses (4)
  • Design (36)
    • UX/UI (6)
  • DevOps (55)
    • CI/CD (2)
    • Docker (29)
    • GIT (25)
  • Histories (10)
  • Life (72)
    • Books (27)
    • Tips and Tricks (13)
    • พุทธ (3)
  • Network (114)
    • Apache HTTP Server (13)
    • IOT (1)
    • Nginx (27)
    • Stalwart (5)
  • Operating Systems (242)
    • Unix-like (171)
      • Android (13)
      • iPhone (5)
      • Linux (107)
      • macOS (84)
        • Homebrew (15)
        • OrbStack (10)
      • Oh My ZSH (4)
      • Shell Script (32)
      • SSH (11)
    • Windows (111)
      • PowerShell (23)
      • WSL (24)
  • Programming (646)
    • .NET (18)
      • .NET Core EF (5)
      • C# (17)
    • API (21)
      • REST (5)
      • Swagger (6)
    • Database (173)
      • DBeaver (3)
      • MariaDB (26)
      • MySql (64)
      • Oracle Database (5)
        • 10g (2)
      • PostgreSQL (6)
      • RDBMS (1)
      • SQL Server (84)
        • SSMS (8)
        • T-SQL (26)
      • SQLite (1)
    • PowerBuilder (10)
    • Python (1)
    • Rust (1)
    • System Analyst (SA) (1)
    • Testing (11)
      • Automated Testing (3)
    • UML (2)
    • Web (339)
      • Backend (218)
        • Golang (1)
        • Java (44)
          • Spring Boot (14)
        • Node.js (1)
        • PHP (173)
          • Laravel (16)
          • Yii (5)
      • Frontend (120)
        • CSS (15)
          • Tailwind CSS (3)
        • JavaScript (111)
          • Angular (2)
          • jQuery (60)
          • Tabulator (11)
          • Vue.js (3)
      • WordPress (25)
  • Programs (72)
    • Excel (9)
  • Security (46)
  • กฎหมาย (6)

Sirat WordPress Theme By VWThemes

Scroll Up
Go to mobile version