docker-compose + Apache2 + php-fpm Не удалось подключиться к порту {URL} 80: соединение отклонено - PullRequest
0 голосов
/ 28 ноября 2018

У меня проблема при попытке настроить мой docker-compose.У меня есть 2 веб-сайта, которые должны быть связаны друг с другом, но когда я пытаюсь сделать curl внутри php-fpm, ответ будет таким:

curl: (7) Failedподключиться к порту dev.test.adgo-tech.com 80: Соединение отклонено

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

В других потоках я видел, что проблема в VirtualHost, и необходимо добавить эту строку, ноЯ не могу заставить его работать.

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

Я начинаю видеть, как работает docker-composeтак что мой уровень очень низкий.Если вам нужно показать другой файл, скажите мне поставить его здесь

Спасибо

...