我正在尝试解决我的应用程序的问题。当我在桌面上本地启动我的应用程序时,一切都很好。当我在 docker 中启动它并发送帖子或获取请求时,我收到了 Postman 431Request Header Fields Too Large 的响应。 有人可以帮我吗? 对此 url 的 HTTP GET 请求 GET http://localhost:8181/api/product 这是我的 docker compose 文件
---
version: '3.7'
services:
## MySQL Docker Compose Config
postgres-order:
container_name: postgres-order
image: postgres
environment:
POSTGRES_DB: order-service
POSTGRES_USER: ptechie
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- ./postgres-order:/data/postgres
expose:
- "5431"
ports:
- "5431:5431"
command: -p 5431
restart: always
postgres-inventory:
container_name: postgres-inventory
image: postgres
environment:
POSTGRES_DB: inventory-service
POSTGRES_USER: ptechie
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
volumes:
- ./postgres-inventory:/data/postgres
ports:
- "5432:5432"
restart: always
## Mongo Docker Compose Config
mongo:
container_name: mongo
image: mongo:4.4.14-rc0-focal
restart: always
ports:
- "27017:27017"
expose:
- "27017"
volumes:
- ./mongo-data:/data/db
zookeeper:
image: confluentinc/cp-zookeeper:7.0.1
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
broker:
image: confluentinc/cp-kafka:7.0.1
container_name: broker
ports:
- "9092:9092"
depends_on:
- zookeeper
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,PLAINTEXT_INTERNAL://broker:29092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
# ## Zipkin
# zipkin:
# image: openzipkin/zipkin
# container_name: zipkin
# ports:
# - "9411:9411"
#
## Eureka Server
discovery-server:
image: danicazdravkovic/discovery-server:latest
container_name: discovery-server
ports:
- "8761:8761"
environment:
- SPRING_PROFILES_ACTIVE=docker
# depends_on:
# - zipkin
api-gateway:
image: danicazdravkovic/api-gateway:latest
container_name: api-gateway
ports:
- "8181:8080"
expose:
- "8181"
environment:
- SPRING_PROFILES_ACTIVE=docker
# - LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_SECURITY= TRACE
depends_on:
# - zipkin
- discovery-server
## Product-Service Docker Compose Config
product-service:
container_name: product-service
image: danicazdravkovic/product-service:latest
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- mongo
- discovery-server
- api-gateway
## Order-Service Docker Compose Config
order-service:
container_name: order-service
image: danicazdravkovic/order-service:latest
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres-order:5431/order-service
depends_on:
- postgres-order
- broker
# - zipkin
- discovery-server
- api-gateway
## Inventory-Service Docker Compose Config
inventory-service:
container_name: inventory-service
image: danicazdravkovic/inventory-service:latest
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres-inventory:5432/inventory-service
depends_on:
- postgres-inventory
- discovery-server
- api-gateway
## Notification-Service Docker Compose Config
notification-service:
container_name: notification-service
image: danicazdravkovic/notification-service:latest
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
# - zipkin
- broker
- discovery-server
- api-gateway
这是日志
2023-08-28 14:47:10 2023-08-28T12:47:10.695Z DEBUG 1 --- [or-http-epoll-3] .f.h.o.ObservedResponseHttpHeadersFilter : Will instrument the response
2023-08-28 14:47:10 2023-08-28T12:47:10.696Z DEBUG 1 --- [or-http-epoll-3] .f.h.o.ObservedResponseHttpHeadersFilter : The response was handled for observation {name=http.client.requests(null), error=null, context=name='http.client.requests', contextualName='null', error='null', lowCardinalityKeyValues=[http.method='GET', http.status_code='UNKNOWN', spring.cloud.gateway.route.id='product-service', spring.cloud.gateway.route.uri='lb://product-service'], highCardinalityKeyValues=[http.uri='http://localhost:8181/api/product'], map=[class io.micrometer.core.instrument.Timer$Sample='io.micrometer.core.instrument.Timer$Sample@745b2658', class io.micrometer.core.instrument.LongTaskTimer$Sample='SampleImpl{duration(seconds)=1.090919261, duration(nanos)=1.090919261E9, startTimeNanos=7682403671438}'], parentObservation={name=http.server.requests(null), error=null, context=name='http.server.requests', contextualName='null', error='null', lowCardinalityKeyValues=[exception='none', method='GET', outcome='SUCCESS', status='200', uri='UNKNOWN'], highCardinalityKeyValues=[http.url='/api/product'], map=[class io.micrometer.core.instrument.Timer$Sample='io.micrometer.core.instrument.Timer$Sample@159ad82d', class io.micrometer.core.instrument.LongTaskTimer$Sample='SampleImpl{duration(seconds)=1.097201581, duration(nanos)=1.097201581E9, startTimeNanos=7682397843526}'], parentObservation=null}}
2023-08-28 14:47:10 2023-08-28T12:47:10.697Z TRACE 1 --- [or-http-epoll-3] o.s.c.g.filter.NettyWriteResponseFilter : NettyWriteResponseFilter start inbound: 2f267dd5, outbound: [690e1732-641]
2023-08-28 14:47:10 2023-08-28T12:47:10.699Z TRACE 1 --- [or-http-epoll-3] o.s.c.g.filter.GatewayMetricsFilter : spring.cloud.gateway.requests tags: [tag(httpMethod=GET),tag(httpStatusCode=431),tag(outcome=CLIENT_ERROR),tag(routeId=product-service),tag(routeUri=lb://product-service),tag(status=REQUEST_HEADER_FIELDS_TOO_LARGE)]
我正在阅读有关更改标头大小的信息,但我不知道如何在 docker compose 文件和 Docker 容器中执行此操作
嗨@Danica,我在我点击的每个 Api 请求中仍然遇到请求标头太大错误,我已经在 docker compose 中映射了数据库 url,并且应用程序属性仅适用于 produvt 服务、库存服务和订单服务。但仍然面临同样的问题.这个问题上的任何帮助都会很好。我需要在 Api 网关配置中的任何地方进行更改吗?请建议