docker-compose + Apache2 + php-fpm无法连接到{URL}端口80:连接被拒绝

I have a problem when I' trying configuring my docker-compose. I have 2 websites that have to be connected to each other but when I try to do a curl inside php-fpm the response is this :

curl: (7) Failed to connect to dev.test.adgo-tech.com port 80: Connection refused

docker-compose.yaml

version: '2'

services:

  ###
  ### APLICACIONES
  ###
  aplicaciones:
    image: tianon/true
    volumes:
    # Proyectos al mismo nivel de dockbox
    - ${APPLICATION}:/var/www


  ###
  ### SERVIDOR UBUNTU 16.04
  ###
  servidor:
    build:
      context: ./server
      dockerfile: "Dockerfile-${PHP_VERSION}"
      args:
      - INSTALL_XDEBUG=${WORKSPACE_INSTALL_XDEBUG}
      - INSTALL_SOAP=${WORKSPACE_INSTALL_SOAP}
      - INSTALL_MONGO=${WORKSPACE_INSTALL_MONGO}
      - INSTALL_MSSQL=${WORKSPACE_INSTALL_MSSQL}
      - INSTALL_NODE=${WORKSPACE_INSTALL_NODE}
      - INSTALL_YARN=${WORKSPACE_INSTALL_YARN}
      - INSTALL_SASS=${WORKSPACE_INSTALL_SASS}
      - INSTALL_V8JS_EXTENSION=${WORKSPACE_INSTALL_INSTALL_V8JS_EXTENSION}
      - COMPOSER_GLOBAL_INSTALL=${WORKSPACE_COMPOSER_GLOBAL_INSTALL}
      - INSTALL_WORKSPACE_SSH=${WORKSPACE_INSTALL_WORKSPACE_SSH}
      - INSTALL_LARAVEL_ENVOY=${WORKSPACE_INSTALL_LARAVEL_ENVOY}
      - INSTALL_LARAVEL_INSTALLER=${WORKSPACE_INSTALL_LARAVEL_INSTALLER}
      - INSTALL_DEPLOYER=${WORKSPACE_INSTALL_DEPLOYER}
      - INSTALL_MC=${WORKSPACE_INSTALL_MC}
      - INSTALL_SYMFONY=${WORKSPACE_INSTALL_SYMFONY}
      - INSTALL_PYTHON=${WORKSPACE_INSTALL_PYTHON}
      - INSTALL_IMAGE_OPTIMIZERS=${WORKSPACE_INSTALL_IMAGE_OPTIMIZERS}
      - INSTALL_ZMQ=${WORKSPACE_INSTALL_ZMQ}
      - PUID=${WORKSPACE_PUID}
      - PGID=${WORKSPACE_PGID}
      - NODE_VERSION=${WORKSPACE_NODE_VERSION}
      - YARN_VERSION=${WORKSPACE_YARN_VERSION}
      - TZ=${WORKSPACE_TIMEZONE}
    volumes_from:
    - aplicaciones
    extra_hosts:
    # IMPORTANT: Replace with your Docker Host IP (will be appended to /etc/hosts)
    # OBTENER CON: docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
    - "dockerhost:${DOCKER_HOST_IP}"
    ports:
    - "${WORKSPACE_SSH_PORT}:22"
    tty: true
    networks:
    - frontend
    - backend


  ###
  ### PHP
  ###
  php-fpm:
    build:
      context: ./php-fpm
      dockerfile: "Dockerfile-${PHP_VERSION}"
      args:
      - INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG}
      - INSTALL_SOAP=${PHP_FPM_INSTALL_SOAP}
      - INSTALL_MONGO=${PHP_FPM_INSTALL_MONGO}
      - INSTALL_MSSQL=${PHP_FPM_INSTALL_MSSQL}
      - INSTALL_ZIP_ARCHIVE=${PHP_FPM_INSTALL_ZIP_ARCHIVE}
      - INSTALL_BCMATH=${PHP_FPM_INSTALL_BCMATH}
      - INSTALL_PHPREDIS=${PHP_FPM_INSTALL_PHPREDIS}
      - INSTALL_MEMCACHED=${PHP_FPM_INSTALL_MEMCACHED}
      - INSTALL_OPCACHE=${PHP_FPM_INSTALL_OPCACHE}
      - INSTALL_EXIF=${PHP_FPM_INSTALL_EXIF}
      - INSTALL_MYSQLI=${PHP_FPM_INSTALL_MYSQLI}
      - INSTALL_TOKENIZER=${PHP_FPM_INSTALL_TOKENIZER}
      - INSTALL_INTL=${PHP_FPM_INSTALL_INTL}
      - INSTALL_GHOSTSCRIPT=${PHP_FPM_INSTALL_GHOSTSCRIPT}
      - INSTALL_LDAP=${PHP_FPM_INSTALL_LDAP}
      - INSTALL_SWOOLE=${PHP_FPM_INSTALL_SWOOLE}
      - INSTALL_IMAGE_OPTIMIZERS=${PHP_FPM_INSTALL_IMAGE_OPTIMIZERS}
      - INSTALL_ZMQ=${PHP_FPM_INSTALL_ZMQ}
    volumes_from:
    - aplicaciones
    volumes:
    - ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini
    expose:
    - "9000"
    depends_on:
    - servidor
    extra_hosts:
    - "dockerhost:${DOCKER_HOST_IP}"
    - "dev.test.adgo-tech.com:172.20.0.4"
    environment:
    - PHP_IDE_CONFIG=${PHP_IDE_CONFIG}
    networks:
    - backend


  ###
  ### NGINX
  ###
  nginx:
    build:
      context: ./nginx
      args:
      - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER}
      - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT}
    volumes_from:
    - aplicaciones
    volumes:
    - ${NGINX_HOST_LOG_PATH}:/var/log/nginx
    - ${NGINX_SITES_PATH}:/etc/nginx/sites-available
    ports:
    - "${NGINX_HOST_HTTP_PORT}:80"
    - "${NGINX_HOST_HTTPS_PORT}:443"
    depends_on:
    - php-fpm
    networks:
    - frontend
    - backend


  ###
  ### APACHE
  ###
  apache2:
    build:
      context: ./apache2
      args:
      - PHP_UPSTREAM_CONTAINER=${APACHE_PHP_UPSTREAM_CONTAINER}
      - PHP_UPSTREAM_PORT=${APACHE_PHP_UPSTREAM_PORT}
    volumes_from:
    - aplicaciones
    volumes:
    - ${APACHE_HOST_LOG_PATH}:/var/log/apache2
    - ./apache2/sites:/etc/apache2/sites-available
    ports:
    - "${APACHE_HOST_HTTP_PORT}:80"
    - "${APACHE_HOST_HTTPS_PORT}:443"
    - "${APACHE_HOST_SERVER_PORT}:5233"
    - "${APACHE_HOST_ZMQ_PORT}:5555"
    - 9000:9000
    depends_on:
    - php-fpm
    networks:
    - frontend
    - backend


  ###
  ### MYSQL
  ###
  mysql:
    build:
      context: ./mysql
      args:
      - MYSQL_VERSION=${MYSQL_VERSION}
    environment:
    - MYSQL_DATABASE=${MYSQL_DATABASE}
    - MYSQL_USER=${MYSQL_USER}
    - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
    - TZ=${WORKSPACE_TIMEZONE}
    volumes:
    - ${DATA_SAVE_PATH}/mysql:/var/lib/mysql
    - ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d
    ports:
    - "${MYSQL_PORT}:3306"
    user: "1000:50"
    networks:
    - backend

vhost.conf

<VirtualHost *:80>
  ServerName dev.test.adgo-tech.com
  DocumentRoot /var/www/core/web
  Options Indexes FollowSymLinks
  <Directory "/var/www/core/web">
    AllowOverride All
    <IfVersion < 2.4>
      Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
      Require all granted
    </IfVersion>
  </Directory>
</VirtualHost>

docker-compose exec php-fpm bash

hosts

127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.20.0.2      dockerhost
172.20.0.4      dev.test.adgo-tech.com
172.20.0.4      c32dab0d80ff

I saw in the others threads that problem is in VirtualHost and it's necessary add this line but I can't get it to work.

SetHandler "proxy:fcgi://php:9000"

I'm starting to see how docker-compose works so my level is very low. If you need to show another file tell me to put it here

Thank you

douzhang1926
douzhang1926 执行此命令时:dockerinspect-f'{{。Name}}-{{range.NetworkSettings.Networks}}{{。IPAddress}}{{end}}'$(dockerps-aq)返回:dockbox_apache2_1-172.20.0.5172.19.0.3/dockbox_php-fpm_1-172.20.0.4/dockbox_servidor_1-172.20.0.3172.19.0.2/dockbox_mysql_1-172.20.0.2
接近 2 年之前 回复
douzai3399
douzai3399 IP地址172.20.0.4来自哪里?
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐