问题描述
我可以使用本地的http:// localhost:8080基地址将发布请求发送到Nuxeo服务器。当我向应用程序添加docker支持时,我的应用程序无法使用http:// nuxeo_container_name:80基地址将发布请求发送至nuxeo服务器。它返回badRequest。我该如何解决? Nuxeo服务器和应用程序位于同一docker网络中。 这是我为nuxeo服务器准备的docker-compose。我在应用中使用nuxeo_app_server作为nuxeo容器名称。
version: "3.5"
networks:
nuxnet:
name: network
services:
Nginx:
container_name: nuxeo_app_server
build: Nginx
ports:
# For localhost use,the exposed Nginx port
# must match the localhost:port below in NUXEO_URL
- "8080:80"
#- "443:443"
cap_add:
- NET_BIND_SERVICE
links:
- nuxeo1
# - nuxeo2
environment:
USE_STAGING: 1
# default is 4096,but gcloud requires 2048
KEYSIZE: 2048
DOMAIN_LIST: /etc/Nginx/conf.d/domains.txt
devices:
- "/dev/urandom:/dev/random"
sysctls:
- net.core.somaxconn=511
volumes:
- ./Nginx/conf.d:/etc/Nginx/conf.d:ro
- certs:/etc/ssl/acme
networks:
- nuxnet
restart: always
nuxeo1:
image: nuxeo
hostname: nuxeo1
links:
- redis
- es
- db
env_file:
- ./nuxeo/setup.env
environment:
# Each nuxeo container must have a unique cluster id
NUXEO_CLUSTER_ID: 1
# URL that a user would use to access nuxeo UI or API
# For localhost urls,the port must match the exposted Nginx port above
NUXEO_URL: http://localhost:8080/nuxeo
# JAVA memory tuning -xms,-Xmx
JVM_MS: 1024m
JVM_MX: 2048m
devices:
- "/dev/urandom:/dev/random"
volumes:
- ./nuxeo/init:/docker-entrypoint-initnuxeo.d:ro
- app-data:/var/lib/nuxeo
- app-logs:/var/log/nuxeo
networks:
- nuxnet
restart: always
redis:
# note: based on alpine:3.6
# see https://hub.docker.com/_/redis/
image: redis:3.2-alpine
volumes:
- redis-data:/data
networks:
- nuxnet
restart: always
es:
image: elasticsearch:2.4-alpine
volumes:
- es-data:/usr/share/elasticsearch/data
- es-plugins:/usr/share/elasticsearch/plugins
- es-config:/usr/share/elasticsearch/config
- ./elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
environment:
# settings below add -xms400m -Xmx1g
ES_MIN_MEM: 500m
EX_MAX_MEM: 1g
security_opt:
- seccomp:unconfined
networks:
- nuxnet
restart: always
db:
image: postgres:9.6-alpine
# note mem tuning suggestions in the following two links
# https://doc.nuxeo.com/nxdoc/postgresql/
# https://doc.nuxeo.com/nxdoc/postgresql/#adapt-your-configuration-to-your-hardware
environment:
POSTGRES_USER: nuxeo
POSTGRES_PASSWORD: nuxeo
POSTGRES_DB: nuxeo
POSTGRES_INITDB_ARGS: "-E UTF8"
PGDATA: /var/lib/postgresql/data
volumes:
- db-store:/var/lib/postgresql/data
- ./postgresql/postgresql.conf:/etc/postgresql.conf:ro
command: postgres -c config_file=/etc/postgresql.conf
networks:
- nuxnet
restart: always
volumes:
# to view current data,run bin/view-data.sh
certs:
app-logs: # all server logs,can be shared between instances
app-data: # contains app data and packages (store cache),can be shared between instances
db-store: # postgres database
es-data:
es-plugins:
es-config:
redis-data:
解决方法
我成功使用容器名称和默认端口在两个容器之间发出了REST请求。
您尝试使用URL:http:// nuxeo1:8080吗?