几天来我一直无法将我的应用程序部署在多码头集装箱上。我正在运行一个nginx docker容器,该容器应该反向代理到我的dockerized节点应用程序。当我运行eb local run时,一切正常运行,并且我无法弄清楚为什么通过弹性beantalk部署时它不起作用。我整天都尝试了多种不同的配置更改,但我该做的不知所措。有人有什么建议吗?
我从EC2实例在NGINX的日志中遇到的错误是:
2018/12/04 04:18:44 [error] 6#6: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 136.49.25.164, server: , request: "GET / HTTP/1.1", upstream: "http://172.17.0.2:3000/", host: "inventorio-env-1.2vkt3bwr3w.us-east-1.elasticbeanstalk.com"
以下是相关的配置: Dockerrun.aws.json:
{
"AWSEBDockerrunVersion": 2,
"volumes": [
{
"name": "inventorio",
"host": {
"sourcePath": "/var/app/current/inventorio"
}
},
{
"name": "nginx-proxy-conf",
"host": {
"sourcePath": "/var/app/current/proxy/conf.d"
}
}
],
"containerDefinitions": [
{
"name": "inventorio",
"image": "jpwarren13/inventor-io:docker3",
"essential": true,
"memory": 128,
"mountPoints": [
{
"sourceVolume": "inventorio",
"containerPath": "/var/www/html",
"readOnly": true
}
]
},
{
"name": "nginx-proxy",
"image": "nginx",
"essential": true,
"memory": 128,
"portMappings": [
{
"hostPort": 80,
"containerPort": 80
}
],
"links": ["inventorio"],
"mountPoints": [
{
"sourceVolume": "inventorio",
"containerPath": "/var/www/html",
"readOnly": true
},
{
"sourceVolume": "nginx-proxy-conf",
"containerPath": "/etc/nginx/conf.d",
"readOnly": true
},
{
"sourceVolume": "awseb-logs-nginx-proxy",
"containerPath": "/var/log/nginx"
}
]
}
]
}
Dockerfile:
FROM node:11.2.0
# Create app directory
WORKDIR /var/www/html
# Install app dependencies
COPY package*.json ./
# For npm@5 or later, copy package-lock.json as well
# COPY package.json package-lock.json .
RUN npm install
# Bundle app source
COPY . .
EXPOSE 3000
CMD [ "npm", "run", "start:docker" ]
proxy / conf.d / default.conf:
upstream inventorio{
server inventorio:3000;
}
server {
listen 80;
# server_name localhost;
root /var/www/html;
index index.html;
location /{
proxy_pass http://inventorio;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
我还尝试为根请求添加try_files指令并获取:
2018/12/04 03:03:04 [error] 6#6: *1 open() "/var/app/current/appindex.html" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /sw.js HTTP/1.1", host: "localhost", referrer: "http://localhost/sw.js"