docker run -d \
--name ansible \
-p 5000:5000 \
-e ANSIBLE_HOST_KEY_CHECKING=False \
-e ADMIN_USERNAME=admin123 \
-e ADMIN_PASSWORD=admin123 \
-v ./ansible:/app/db \
dapiaoliang666/ansible
2:安全访问:
生产环境建议用nginx反代,并用nginx开启白名单访问限制和HTTPS,以下是docker-compose示例配置:
services:
ansible:
image: dapiaoliang666/ansible
container_name: ansible
environment:
- ANSIBLE_HOST_KEY_CHECKING=False
- ADMIN_USERNAME=admin123
- ADMIN_PASSWORD=admin123
volumes:
- ./ansible:/app/db
restart: always
nginx:
image: nginx:alpine
container_name: nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
restart: always
nginx.conf白名单示例
server {
listen 80;
# listen 443 ssl;
# 允许访问的 IP 地址
allow 192.168.0.12;
deny all;
location / {
proxy_pass http://ansible:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 支持 WebSocket 连接
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
}
Content type
Image
Digest
sha256:a4525dadd…
Size
78.1 MB
Last updated
almost 2 years ago
docker pull dapiaoliang666/ansible