ผู้ใช้และสิทธิ์ของ RabbitMQ
จัดการผู้ใช้ โฮสต์เสมือน และสิทธิ์ภายใน RabbitMQ เพื่อควบคุมการเข้าถึงทรัพยากร ใช้นโยบายความปลอดภัยแบบละเอียดสำหรับสภาพแวดล้อมการส่งข้อความของคุณ
ผู้ใช้และสิทธิ์ของ RabbitMQ เป็นบทเรียน RabbitMQ Messaging & Async Systems ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน RabbitMQ Messaging & Async Systems และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส RabbitMQ Messaging & Async Systems มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Why Security Matters in RabbitMQ
In any messaging system, controlling who can send and receive messages is crucial. RabbitMQ provides robust mechanisms to manage access, ensuring only authorized users interact with your message broker.
This lesson will guide you through setting up users, virtual hosts, and permissions to secure your RabbitMQ environment.
Users: Your First Line of Defense
A user in RabbitMQ represents an application or person connecting to the broker. Each user has a username and password for authentication.
By default, RabbitMQ creates a 'guest' user, but it's best practice to create dedicated users for your applications.
To create a new user, you use the rabbitmqctl command:
rabbitmqctl add_user my_app_user strong_passwordVirtual Hosts (Vhosts) for Isolation
Virtual hosts (or vhosts) act like separate, isolated RabbitMQ brokers within a single instance. They provide logical grouping and resource separation for different applications or environments.
- Each vhost has its own exchanges, queues, and bindings.
- Users are granted permissions to specific vhosts.
To create a vhost:
rabbitmqctl add_vhost /my_application_vhostThe Three Pillars of Permissions
Once you have users and vhosts, you need to define what each user can do within a specific vhost. RabbitMQ permissions are categorized into three types:
- Configure: For creating, deleting, and altering exchanges and queues.
- Write: For sending (publishing) messages to exchanges.
- Read: For receiving (consuming) messages from queues.
Configure Permissions: Managing Resources
The configure permission allows a user to manage RabbitMQ resources like exchanges and queues. If a user needs to declare (create) or delete queues and exchanges, they need this permission.
The permission regex applies to the names of the resources.
rabbitmqctl set_permissions \
-p /my_vhost \
my_app_user \
"^my_queue.*" \
".*" \
".*"Write Permissions: Sending Messages
The write permission allows a user to publish messages to exchanges within a vhost. Without this, a producer application cannot send messages.
The regex in the second position defines which exchanges the user can write to.
rabbitmqctl set_permissions \
-p /my_vhost \
my_app_user \
".*" \
"^my_exchange.*" \
".*"Read Permissions: Receiving Messages
The read permission allows a user to consume messages from queues within a vhost. This is essential for consumer applications to receive messages.
The regex in the third position defines which queues the user can read from.
rabbitmqctl set_permissions \
-p /my_vhost \
my_app_user \
".*" \
".*" \
"^my_queue.*"Granting Full Access to a Vhost
Often, an application user needs full control over their dedicated vhost. You can grant all three permissions (configure, write, read) to a user for all resources in a vhost using the ".*" regex for all three permission types.
This means 'match any resource name'.
rabbitmqctl set_permissions \
-p /my_vhost \
my_app_user \
".*" \
".*" \
".*"The Special 'Guest' User
RabbitMQ comes with a default user named guest with password guest. This user has full administrative permissions over all vhosts.
- Crucially: The 'guest' user can only connect from
localhostby default. - For production environments, it is highly recommended to delete this user or change its password and restrict its access, and create specific users with minimal necessary permissions.
Permission Check
A new application needs to connect to RabbitMQ, declare a queue named 'tasks_queue', and then consume messages from it. Which set of permissions does its user need on the /app_vhost?
Recap: Users, Vhosts & Permissions
You've learned how to secure your RabbitMQ instance by managing user access. Here's a quick summary:
- Users authenticate client applications.
- Virtual Hosts (Vhosts) provide isolated environments.
- Permissions (Configure, Write, Read) control what users can do within a vhost.
- Always use specific users and minimal permissions, especially for production.
Next, we'll explore how to encrypt these connections with SSL/TLS!
เรียนรู้ RabbitMQ Messaging & Async Systems ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 11
- บทเรียน
- 44
คำถามที่พบบ่อย
บทเรียน “ผู้ใช้และสิทธิ์ของ RabbitMQ” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ผู้ใช้และสิทธิ์ของ RabbitMQ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส RabbitMQ Messaging & Async Systems ให้อัปเกรดเป็น CoddyKit PRO คอร์ส RabbitMQ Messaging & Async Systems มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ผู้ใช้และสิทธิ์ของ RabbitMQ”
จัดการผู้ใช้ โฮสต์เสมือน และสิทธิ์ภายใน RabbitMQ เพื่อควบคุมการเข้าถึงทรัพยากร ใช้นโยบายความปลอดภัยแบบละเอียดสำหรับสภาพแวดล้อมการส่งข้อความของคุณ คุณปฏิบัติ RabbitMQ Messaging & Async Systems ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน RabbitMQ Messaging & Async Systems หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน RabbitMQ Messaging & Async Systems บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “ผู้ใช้และสิทธิ์ของ RabbitMQ” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน RabbitMQ Messaging & Async Systems นี้ได้ไหม
ได้ บทเรียน RabbitMQ Messaging & Async Systems ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ผู้ใช้และสิทธิ์ของ RabbitMQ
- SSL/TLS สำหรับการเชื่อมต่อที่ปลอดภัย
- ปลั๊กอินจัดการ RabbitMQ และเมตริก
- โฮสต์เสมือนเพื่อแยกผู้เช่าหลายราย