我在Digitalocean Linux服务器上的Docker容器上运行微服务应用程序。
在本地,他们工作正常,当我在服务器上运行他们时,他们可以从全球网络访问,但他们不能相互通信,说连接超时。
这是我的Docker合成文件
version: '3.4'
services:
app.identityserver:
image: registry.digitalocean.com/app/appidentityserver:latest
build:
context: .
dockerfile: App.IdentityServer/Dockerfile
ports:
- 6004:6004
- 6005:6005
#- 6004:443
#- 6005:80
container_name: appidentityserver
environment:
- ApiUrl=https://dev.mydomain.net:6000
- ChatHubApiUrl=https://dev.mydomain.net:6100
- MediaServerPath=https://dev.mydomain.net:6200
- MailServiceUrl=https://dev.mydomain.net:6300
- DefaultConnection=***
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:6004;http://+:6005
- ASPNETCORE_HTTPS_PORT=6004
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/sslCert/archive/cert1.pem
- ASPNETCORE_Kestrel__Certificates__Default__KeyPath=/app/sslCert/archive/privkey1.pem
volumes:
- /etc/letsencrypt/archive/dev.mydomain.net/:/app/sslCert/archive/
app.api:
image: registry.digitalocean.com/yekka/appapi:latest
build:
context: .
dockerfile: App/Dockerfile
ports:
- 6000:443
#- 6001:80
container_name: appapi
environment:
- IedntityServerUrl=https:dev.mydomain.net:6004
- DefaultConnection=***
- ChatHubPath=https://dev.mydomain.net:6100
- MediaServerPath=https://dev.mydomain.net:6200
- MailServicePath=https://dev.mydomain.net:6300
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+;http://+
- ASPNETCORE_HTTPS_PORT=6000
- ASPNETCORE_Kestrel__Certificates__Default__Path=/app/sslCert/archive/cert1.pem
- ASPNETCORE_Kestrel__Certificates__Default__KeyPath=/app/sslCert/archive/privkey1.pem
volumes:
- /etc/letsencrypt/archive/dev.mydomain.net/:/app/sslCert/archive/
depends_on:
- app.identityserver
容器在同一个网络上,我可以dev.mydomain.net从容器内部ping www.example.com,但不能从容器内部用curl攻击容器。我也可以从主机上curl容器,反之亦然。
有什么想法吗?我已经纠结了好几天了,请帮帮我:)
1条答案
按热度按时间mtb9vblg1#
我刚刚发现我的UFW中不允许有集装箱的港口。现在可以了。