【发布时间】:2019-09-24 22:27:52
【问题描述】:
我有一个在 Elastic Beanstalk 上运行的应用程序。此应用程序导出 Docker 容器的两个端口。 Nginx 只取第一个,所以我得改配置再添加一个。
在this post 和AWS documentation 之后,我正在尝试扩展 nginx 配置以添加另一个上游,因此我创建了更多文件来执行此操作:
files:
"/etc/nginx/conf.d/api-port.conf":
mode: "000644"
owner: root
group: root
content: |
upstream docker {
server 172.17.0.2:4003;
keepalive 256;
}
server {
listen 4003;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
access_log /var/log/nginx/access.log;
location / {
proxy_pass http://docker;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
此文件部署在文件夹 .ebextensions/nginx/conf.d/api-port.conf 中并复制到 EC2 实例,但它不起作用,也没有复制到 /etc/nginx/conf.d。
知道发生了什么吗?
提前致谢
【问题讨论】:
标签: docker nginx amazon-elastic-beanstalk