【发布时间】:2019-02-21 10:16:57
【问题描述】:
我正在本地构建一个使用微服务的应用程序,然后在 docker 容器上构建 我目前有 Eureka、带有 Spring Security 的 Zuul、一个使用 Spring boot 2 的微服务和一个 Angular 6 客户端
我在 Zuul 上对 Spring Security 进行了参数化以管理安全性和 CORS,扩展 WebSecurityConfigurerAdapter 类,覆盖 configure 方法,...
在本地它完美地工作。我的客户 (http://localhost:4200) 可以通过 Zuul (http://localhost:8762/microservice/api/...) 访问 API,并使用 OPTION 添加基本身份验证标头。
但是对于使用 Docker Compose 构建的 Docker 容器,情况就不一样了。 Chrome 抛出“未知异常”,而 Firefox 在 选项请求。客户端通过 Zuul 调用 API,如下所示:http://gdt-gateway-proxy-service:8762/microservice/api/...
这是我的docker-compose.yml 文件的一部分,涉及客户端 (gdt-client) 和 Zuul (gdt-gateway-proxy-service):
version: '2'
services:
...
gdt-gateway-proxy-service:
container_name: alpine-jdk8-gdt-gateway-proxy-service
build:
context: .
dockerfile: Dockerfile.gdt-gateway-proxy-service
image: alpine-jdk8-gdt-gateway-proxy-service:latest
...
expose:
- 8762
ports:
- 8762:8762
networks:
- gdt-network
...
gdt-client:
container_name: alpine-httpd-gdt-client
build:
context: .
dockerfile: Dockerfile.alpine.httpd-gdt-client
image: alpine-httpd-gdt-client:base
expose:
- 4200
ports:
- 4200:80
networks:
- gdt-network
links:
- gdt-gateway-proxy-service:gdt-gateway-proxy-service
depends_on:
- gdt-gateway-proxy-service
logging:
driver: json-file
networks:
gdt-network:
driver: bridge
【问题讨论】:
标签: java spring-boot docker docker-compose microservices