dongyo7931 2018-11-28 07:59
浏览 124

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧
    • ¥15 #MATLAB仿真#车辆换道路径规划