AWS是否支持URL掩码?场景与需求详述
Does AWS support URL masking for redirecting demo2.example.com to demo1.example.com/admin?
Absolutely, AWS supports URL masking (also called hidden redirects) for your exact scenario! This lets users visit demo2.example.com and see content from demo1.example.com/admin while keeping demo2.example.com in their browser's address bar. Below are two reliable implementation approaches tailored to your setup:
Option 1: S3 Static Website Hosting + Route 53 (Simple Setup)
Perfect for straightforward redirect needs, with optional HTTPS support:
- Create an S3 bucket named
demo2.example.com(the bucket name must match your target subdomain exactly—this is a requirement for S3 static site aliases). - Enable "Static website hosting" for the bucket, select "Redirect requests to another host name", and enter
https://demo1.example.com/adminas the target. Choose "Hidden (301 Permanent)" or "Hidden (302 Temporary)" for the redirect type—this is what enables URL masking (the browser address bar won’t update to the demo1 path). - In Route 53, create an Alias record for
demo2.example.compointing to your S3 bucket’s static website endpoint. - HTTPS Note: To serve
demo2.example.comover HTTPS, wrap the S3 bucket with a CloudFront distribution, attach an SSL certificate (from AWS Certificate Manager, ACM) fordemo2.example.com, then point your Route 53 record to the CloudFront domain instead of S3 directly.
Option 2: CloudFront Reverse Proxy (Flexible & HTTPS-Friendly)
Ideal if you need caching, HTTPS, or more control over traffic to your admin panel:
- Create a new CloudFront distribution:
- Set the Origin domain to
demo1.example.com, and enter/adminas the Origin path (this tells CloudFront to fetch content directly from the admin folder of your EC2-hosted site). - Under "Settings", add
demo2.example.comas a Alternate domain name (CNAME). - Attach an SSL certificate for
demo2.example.com(must be issued in theus-east-1AWS region via ACM—CloudFront requires certificates from this region).
- Set the Origin domain to
- In Route 53, create an Alias record for
demo2.example.compointing to your new CloudFront distribution’s domain. - Verify your EC2 web server (e.g., Nginx, Apache) allows requests from
demo2.example.com—you might need to update server blocks or CORS settings if your admin panel uses frontend assets with absolute paths.
Quick Checks
- Confirm your
demo1.example.comEC2 instance is running and accessible (you mentioned it’s active, so this should be covered). - For CloudFront, double-check the origin path to avoid 404 errors—if your admin panel uses hardcoded paths to
demo1.example.com, you may need to adjust your web server to rewrite requests fromdemo2.example.comcorrectly.
内容的提问来源于stack exchange,提问作者amitava deb
相关产品推荐
相关产品推荐

