我想使用Nginx,獨角獸和Django在AWS中設置ECS羣集。使用docker和ngnix的AWS ECS,如何讓我的nginx配置進入容器?
我已經將我的docker-compose.yml轉換爲ECS任務,但是想知道如何讓我的nginx配置進入容器?
這是我在JSON
我已經創建了文件的一些掛載點,但我不能確定如何獲得配置有任務。 當我從本地服務器運行docker時,nginx配置文件對於撰寫文件是本地的,顯然在aws中它不是?
如何通過ecs將nginx配置導入到包含中?
{
"containerDefinitions": [
{
"volumesFrom": null,
"memory": 300,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": null,
"dnsSearchDomains": null,
"portMappings": [
{
"containerPort": 8000,
"protocol": "tcp"
}
],
"hostname": null,
"essential": true,
"entryPoint": null,
"mountPoints": [
{
"containerPath": "/static",
"sourceVolume": "_Static",
"readOnly": null
}
],
"name": "it-app",
"ulimits": null,
"dockerSecurityOptions": null,
"environment": null,
"links": null,
"workingDirectory": "/itapp",
"readonlyRootFilesystem": null,
"image": "*****.amazonaws.com/itapp",
"command": [
"bash",
"-c",
"",
"python manage.py collectstatic --noinput && python manage.py makemigrations && python manage.py migrate && gunicorn itapp.wsgi -b 0.0.0.0:8000"
],
"user": null,
"dockerLabels": null,
"logConfiguration": null,
"cpu": 0,
"privileged": null
},
{
"volumesFrom": null,
"memory": 300,
"extraHosts": null,
"dnsServers": null,
"disableNetworking": null,
"dnsSearchDomains": null,
"portMappings": [
{
"hostPort": 80,
"containerPort": 8000,
"protocol": "tcp"
}
],
"hostname": null,
"essential": true,
"entryPoint": null,
"mountPoints": [
{
"containerPath": "/etc/nginx/conf.d",
"sourceVolume": "_ConfigNginx",
"readOnly": null
},
{
"containerPath": "/static",
"sourceVolume": "_Static",
"readOnly": null
}
],
"name": "nginx",
"ulimits": null,
"dockerSecurityOptions": null,
"environment": null,
"links": [
"it-app"
],
"workingDirectory": null,
"readonlyRootFilesystem": null,
"image": "nginx:latest",
"command": null,
"user": null,
"dockerLabels": null,
"logConfiguration": null,
"cpu": 0,
"privileged": null
}
],
"placementConstraints": [],
"volumes": [
{
"host": {
"sourcePath": "./config/nginx"
},
"name": "_ConfigNginx"
},
{
"host": {
"sourcePath": "./static"
},
"name": "_Static"
}
],
"family": "it-app-task",
"networkMode": "bridge"
}
ngnix配置
upstream web {
ip_hash;
server web:8000;
}
server {
location /static/ {
autoindex on;
alias /static/;
}
location/{
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://web/;
}
listen 8000;
server_name localhost;
}
看看這是否有助於你https://spin.atomicobject.com/2017/05/03/sharing-efs-filesystem-ecs/ –