2014-11-07 41 views
0

我有一个包含2个CNAMES的分发:example.com和www.example.com。我的目标是将www.example.com重定向到example.comCloudFront - CNAME在nginx中不匹配

CloudFront指向一个LoadBalancer,它指向一台EC2计算机。这个EC2机器服务于一个nginx。

我的配置是:

server { 
    listen 80; 
    server_name default; 
    access_log /var/log/nginx/default.access.log; 

    root /xxxx/; 
    index index.html index.htm; 

    location /index.html { 
     add_header "Cache-Control" "public, must-revalidate, proxy-revalidate, max-age=0"; 
    } 
} 

server { 
    listen 80; 
    server_name ~^(www\.)?(?<domain>.+)$; 
    return 301 https://$domain$request_uri; 
} 

的问题是, “服务器名称” 接收 “XXX-YYY-ZZZ-WWW.ap-northeast-1.elb.amazonaws.com”,而不是CNAME(所以我没有获取域的信息)。

任何解决方案?

回答