我有一个docker-compose文件,其中包含nginx,mysql和phpmyadmin。
phpmyadmin在该地址8080
的端口mydomain.com:8080
中也是打开的。
如何在服务器中将此地址转换为http://phpmyadmin.mydomain.com
或http://pma.mydomain.com
?
我使用了这个docker-compose文件:
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: ./Dockerfile/Dockerfile
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./Beh:/var/www
- ./Config/php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "80:80"
# - "443:443"
volumes:
- ./Beh:/var/www
- ./Config/nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
database:
image: mariadb:latest
container_name: database
environment:
- "MYSQL_USERNAME=root"
- "MYSQL_ROOT_PASSWORD=secret"
ports:
- "3306:3306"
networks:
- app-network
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
environment:
- "MYSQL_USERNAME=root"
- "MYSQL_ROOT_PASSWORD=secret"
- "PMA_HOST=database"
links:
- database
ports:
- "8080:80"
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
我不知道如何配置nginx文件来实现此目标。
答案 0 :(得分:0)
您可以使用仓库-> https://github.com/jwilder/nginx-proxy 这就是我用来为每个项目创建新的本地域名的方法。 您必须在环境中添加“ VIRTUAL_HOST”,公开端口(“公开:80”),并在/ etc / hosts中添加新域。