我有一个docker compose文件。我运行3个容器(nginx,postgresql和Java应用程序)
所有容器均已创建。我的问题是,当我想访问我的应用程序时,我使用以下网址:
http://10.34.18.2:81/myProject
,但我一无所有。
我的conf
或yaml
文件有什么问题?
yaml文件:
version: '2'
services:
nginx:
image: 'nginx:latest'
container_name: production_nginx
volumes:
- './nginx.conf:/etc/nginx/nginx.conf'
- './nginx/error.log:/etc/nginx/error_log.log'
- './nginx/cache/:/etc/nginx/cache'
ports:
- '81:80'
- '444:443'
myProject-postgresql:
image: 'postgres:10.4'
environment:
- POSTGRES_USER=myProject
- POSTGRES_PASSWORD=myProject
ports:
- '5432:5432'
myProject-app:
image: myProject
environment:
- '_JAVA_OPTIONS=-Xmx512m -Xms256m'
- 'SPRING_PROFILES_ACTIVE=prod,swagger'
- 'SPRING_DATASOURCE_URL=jdbc:postgresql://myProject-postgresql:5432/myProject'
- JHIPSTER_SLEEP=10
ports:
- '8081:8080'
nginx conf:
server {
listen 81 default_server;
listen [::]:81 default_server;
server_name localhost;
location /myProject {
proxy_pass http://10.34.18.2:8081/;
rewrite ^/myProject(.*)$ $1 break;
}
}