配置Nginx在使用AWS ELB时侦听CNAME

时间:2018-12-11 07:39:07

标签: amazon-web-services nginx

我正在设置一个Web应用程序,该应用程序将使用AWS服务器处理REST请求。我在弹性负载均衡器后面设置了一些EC2实例。我将Nginx用作WSGI,以将请求代理到基于NodeJ的Web应用程序。将Nginx配置为在指向单个EC2实例的A记录时在端口443上监听我的域名,这是在公园散步。但是,AWS建议您在使用ELB时将您的域设置为CNAME。我现在在parse-server-load-balancer-849608942.us-west-2.elb.amazonaws.com上将cloud.deschutesdesigngroup.com设置为指向ELB的CNAME。我该如何配置Nginx来监听cloud.deschutesdesigngroup.com,它不再是解析IP的A记录?

server {
    listen 80;
    keepalive_timeout 70;

    server_name parse-server-load-balancer-849608942.us-west-2.elb.amazonaws.com;

    root         /var/www/html/cloud.deschutesdesigngroup.com;

    index index.html index.htm index.nginx-debian.html;

    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate     /usr/local/nginx/deschutesdesigngroup.crt;
    ssl_certificate_key /usr/local/nginx/deschutesdesigngroup.pem;
    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 10m;

    location / {
            proxy_pass http://127.0.0.1:1337;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
    }
}

0 个答案:

没有答案