0Pricing
Serverless Backend with AWS Lambda & API Gateway · บทเรียน

ชื่อโดเมนแบบกำหนดเองและการเพิ่มประสิทธิภาพที่ขอบเครือข่าย

กำหนดค่าชื่อโดเมนแบบกำหนดเองสำหรับ API และใช้ประโยชน์จากจุดปลายทางที่ปรับให้เหมาะกับขอบเครือข่ายเพื่อเพิ่มประสิทธิภาพทั่วโลก

ชื่อโดเมนแบบกำหนดเองและการเพิ่มประสิทธิภาพที่ขอบเครือข่าย เป็นบทเรียน Serverless Backend with AWS Lambda & API Gateway ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Serverless Backend with AWS Lambda & API Gateway และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Serverless Backend with AWS Lambda & API Gateway มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Your API's Own Address

When you deploy an API Gateway API, AWS provides a default URL. It looks something like https://abcdef123.execute-api.us-east-1.amazonaws.com/prod.

While functional, this URL isn't very user-friendly or brandable. This lesson shows how to use your own domain name!

The Default API Address

Every API Gateway API automatically gets a unique endpoint URL. This URL includes a random ID, the AWS region, and amazonaws.com.

  • Example: https://{restapi_id}.execute-api.{region}.amazonaws.com/{stage_name}
  • It works immediately after deployment.
  • Great for testing, but not ideal for public-facing APIs.

Benefits of Custom Domains

Using a custom domain name for your API offers several advantages:

  • Branding: Use your company's domain (e.g., api.yourcompany.com).
  • Memorability: Easier for users and developers to remember and type.
  • Flexibility: You can change your backend API without changing the public URL.
  • SEO (for web APIs): Helps with search engine optimization.

Securing Your Custom Domain

Before you can use a custom domain, you need an SSL/TLS certificate. This certificate encrypts communication and proves your API's identity.

  • AWS Certificate Manager (ACM) can provision free public SSL certificates.
  • You can also import your own certificate.
  • The certificate must be in the US East (N. Virginia) region for edge-optimized APIs.

Configuring Your Custom Domain

Once you have an SSL certificate, you can configure your custom domain in the API Gateway console.

You'll specify your domain name (e.g., api.example.com) and associate it with the ACM certificate. API Gateway will then create a domain name and provide a DNS target (a CloudFront distribution domain name).

Connecting to Your API

A custom domain needs to know which API Gateway API to route requests to. This is done using base path mappings.

You define a base path (e.g., /v1 or /) and map it to a specific API Gateway API and stage (e.g., prod).

  • api.example.com/v1 -> my-api/prod
  • api.example.com/users -> users-api/prod

Pointing Your Domain

The final step is to update your domain's DNS records. You need to create a CNAME record (or A record if using Route 53 alias) that points your custom domain to the DNS target provided by API Gateway.

This tells the internet that requests for api.example.com should go to the API Gateway's CloudFront distribution.

Global Performance with Edge Optimization

API Gateway offers different endpoint types. Edge-optimized endpoints are the default for REST APIs and are designed for global clients.

They use Amazon CloudFront, AWS's content delivery network (CDN), to route requests through the nearest edge location to your users.

This reduces latency and improves performance for geographically dispersed clients.

CloudFront in Action

When you use an edge-optimized endpoint:

  1. A user's request hits the nearest CloudFront edge location.
  2. CloudFront forwards the request to your API Gateway in the AWS region.
  3. The response is cached at the edge location (if configured) and returned to the user.

This caching and proximity routing significantly speeds up API calls for global users.

Choosing the Right Endpoint Type

API Gateway also supports Regional endpoints. These are best when all your API consumers are in the same AWS region as your API.

  • Edge-Optimized: Default for REST APIs, uses CloudFront, best for global users.
  • Regional: Best for clients in the same region, can be fronted by your own CloudFront distribution for more control.

HTTP APIs only support Regional endpoints by default, but you can add CloudFront yourself.

Custom Domain Check

You want to use api.mydomain.com for your API Gateway API, which will be accessed by users worldwide. Which of the following statements is TRUE?

Recap: Custom Domains & Edge

In this lesson, we learned how to give your API Gateway APIs a professional, branded look using custom domain names. We covered the steps from SSL certificates to DNS configuration.

We also explored edge-optimized endpoints, understanding how they leverage CloudFront to deliver your API with low latency to users across the globe. You now know when to choose between edge-optimized and regional endpoints.

คำถามที่พบบ่อย

บทเรียน “ชื่อโดเมนแบบกำหนดเองและการเพิ่มประสิทธิภาพที่ขอบเครือข่าย” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ชื่อโดเมนแบบกำหนดเองและการเพิ่มประสิทธิภาพที่ขอบเครือข่าย” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Serverless Backend with AWS Lambda & API Gateway ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Serverless Backend with AWS Lambda & API Gateway มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ชื่อโดเมนแบบกำหนดเองและการเพิ่มประสิทธิภาพที่ขอบเครือข่าย”

กำหนดค่าชื่อโดเมนแบบกำหนดเองสำหรับ API และใช้ประโยชน์จากจุดปลายทางที่ปรับให้เหมาะกับขอบเครือข่ายเพื่อเพิ่มประสิทธิภาพทั่วโลก คุณปฏิบัติ Serverless Backend with AWS Lambda & API Gateway ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Serverless Backend with AWS Lambda & API Gateway หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Serverless Backend with AWS Lambda & API Gateway บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “ชื่อโดเมนแบบกำหนดเองและการเพิ่มประสิทธิภาพที่ขอบเครือข่าย” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Serverless Backend with AWS Lambda & API Gateway นี้ได้ไหม

ได้ บทเรียน Serverless Backend with AWS Lambda & API Gateway ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การแคชและการจำกัดอัตรา
  2. การแปลงคำขอและการตอบกลับ
  3. ชื่อโดเมนแบบกำหนดเองและการเพิ่มประสิทธิภาพที่ขอบเครือข่าย
  4. API ของ WebSocket สำหรับการสื่อสารแบบเรียลไทม์
← กลับไปที่ Serverless Backend with AWS Lambda & API Gateway