在Elastic Beanstalk中设置Nginx虚拟主机

我想在Elastic Beanstalk中用Nginx设置2个虚拟主机。

由于我无法将多个SSL证书绑定到ELB,因此我正在使用CloudFront将我想要关联的3个SSL证书提供给不同的子域。
所以我的情况就是这样

Cloudfront ===> ELB ===> EB ==> EC2实例。

我创build了2条指向不同CloudFront分发列表的CNAMElogging,并且当我点击domain1.example.com / domain2.example.com时,我可以看到使用自签名证书在EB上部署的应用的login页面。

我现在想要做的是,为domain1 / domain2和/etc/nginx/nginx.conf创build2个不同的login页面我有这个configuration

 #Elastic Beanstalk Nginxconfiguration文件

用户nginx;
 error_log /var/log/nginx/error.log警告;
 pid /var/run/nginx.pid;
 worker_processes auto;
 worker_rlimit_nofile 133985;

事件{
     worker_connections 5760;
 }

 http {
    包括/etc/nginx/mime.types;
     default_type application / octet-stream;

    log_format main'$ remote_addr  -  $ remote_user [$ time_local]“$ request” 
                      '“$ status $ body_bytes_sent”$ http_referer“'
                       '“$ http_user_agent”“$ http_x_forwarded_for”';

    包括conf.d / *。conf;

     map $ http_upgrade $ connection_upgrade {
        默认“升级”;
     }

    发送文件;
     keepalive_timeout 65;
     gzip on;
     gzip_proxied任何;
     gzip_types text / plain application / xml application / atom + xml application / json;

    服务器{
        听80 default_server;
     server_name example.com;
         access_log /var/log/nginx/access.log main;

         client_header_timeout 60;
         client_body_timeout 60;
         keepalive_timeout 60;
         gzip on;
         gzip_comp_level 4;
         gzip_types text / plain application / xml application / atom + xml application / json;
         #包含Elastic Beanstalk生成的位置
        #include conf.d / elasticbeanstalk / *。conf;
     }
服务器{
    听80;
     server_name domain1.example.com;
    根/ etc / nginx / pages;
     index domain1.html;
    包括/etc/nginx/conf.d/*.conf;
 }

服务器{
    听80;
     server_name domain2.example.com;
     error_page 502 /printer_error.html;
    根/ etc / nginx / pages;
     index domain2.html;
    位置/printer_error.html {
        根/ etc / nginx / pages;
         index printer_error.html;
     }
 }
 }

如果我打到domain2.example.com或domain1.example.com,我总是login到应用程序页面,而不是我的。 有人能发现或告诉我我做错了什么吗?