You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求协助:将AWS ELB地址重定向至指定域名登录页面

Is Redirecting Your ELB Address to Your Custom Domain Feasible? Yes, Here’s How to Do It

Absolutely! Redirecting traffic from your direct ELB address to your desired custom domain path is completely achievable. Below are the most practical methods based on your AWS setup:

Method 1: Use Application Load Balancer (ALB) Built-in Redirect Rules

If you’re using an Application Load Balancer (the modern ELB variant), this is the cleanest approach—it handles redirects at the load balancer level without touching your backend servers:

  1. Navigate to the AWS EC2 Console → Load Balancers → Select your ALB.
  2. Go to the Listeners tab. Configure rules for both HTTP (port 80) and HTTPS (port 443) to cover all possible user access paths.
  3. For the HTTP listener:
    • Click "Edit rules" → Add a new rule.
    • Set the condition to Host header → Enter your ELB domain: rotary-staging-1821321305.us-east-1.elb.amazonaws.com.
    • Set the action to Redirect with these parameters:
      • Protocol: HTTPS
      • Port: 443
      • Host: staging.rotaryisu.com
      • Path: /rotary/frontend/web/site/login (keep the leading slash)
      • Query string: Choose "Keep" if you want to preserve query parameters, or "Discard" if not.
      • Status code: 301 - Permanent Redirect (recommended for long-term changes and SEO) or 302 - Temporary Redirect.
  4. Repeat the same rule setup for the HTTPS listener to cover users accessing the ELB via HTTPS.

Method 2: Configure Backend Server Redirects (For Classic ELB or ALB Rules Aren’t an Option)

If you’re using a Classic Load Balancer or prefer to handle redirects at the backend, configure your web server (Nginx, Apache, etc.) to check the incoming Host header and redirect accordingly:

For Nginx:

Add this server block to your Nginx configuration file:

server {
    listen 80;
    # Add `listen 443 ssl;` here if your backend handles HTTPS directly
    server_name rotary-staging-1821321305.us-east-1.elb.amazonaws.com;
    
    # Redirect to your target URL, preserving query parameters
    return 301 https://staging.rotaryisu.com/rotary/frontend/web/site/login$request_uri;
}

For Apache:

Add this to your .htaccess file or Apache virtual host configuration:

RewriteEngine On
# Match requests to the ELB domain (case-insensitive)
RewriteCond %{HTTP_HOST} ^rotary-staging-1821321305\.us-east-1\.elb\.amazonaws\.com$ [NC]
# Redirect to the target path, preserving the original request URI
RewriteRule ^(.*)$ https://staging.rotaryisu.com/rotary/frontend/web/site/login$1 [R=301,L]

Restart your web server after updating the config to apply changes.

Key Notes to Ensure Success:

  • SSL Certificate: Make sure your target domain (staging.rotaryisu.com) has a valid SSL certificate (e.g., from AWS Certificate Manager) to avoid browser security warnings.
  • Test the Redirect: Use curl -I http://rotary-staging-1821321305.us-east-1.elb.amazonaws.com to verify the redirect returns a 301/302 status code and points to the correct URL.
  • Choose the Right Redirect Code: Use 301 for permanent changes (helps with search engine rankings) and 302 if you might adjust the redirect target later.

内容的提问来源于stack exchange,提问作者Kavendra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:35:08