WebDev2030
@WebDev2030
Битриксоид до мозга и костей

Почему nginx в докере не видит апач?

Пытаюсь собрать через docker-compose себе среду для разработке nginx (80,443 порты) + apache(8887 порт) + php(9000) + mariadb. Апачи видит php-fpm, а nginx не видит apache c ошибкой: no resolver defined to resolve apache2. Сам апач работает если зайти напрямую на 8887 порт то все открывается, но вот через nginx 502 BadGateway
docker-compose.yml
version: '3'

networks:
  backend:
    driver: ${NETWORKS_DRIVER}

services:

  ### Docker-in-Docker ################################################
  docker-in-docker:
    image: docker:dind
    privileged: true
    volumes:
      - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}
      - ${DATA_PATH_HOST}/dind:/var/lib/docker
    expose:
      - 2375
    networks:
      - backend
  ### PHP-FPM ##############################################
  php-fpm:
    build:
      context: ./php-fpm
      args:
        - CHANGE_SOURCE=${CHANGE_SOURCE}
        - LARADOCK_PHP_VERSION=${PHP_VERSION}
        - LARADOCK_PHALCON_VERSION=${PHALCON_VERSION}
        - INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG}
        - INSTALL_PCOV=${PHP_FPM_INSTALL_PCOV}
        - INSTALL_PHPDBG=${PHP_FPM_INSTALL_PHPDBG}
        - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE}
        - INSTALL_SSH2=${PHP_FPM_INSTALL_SSH2}
        - INSTALL_SOAP=${PHP_FPM_INSTALL_SOAP}
        - INSTALL_XSL=${PHP_FPM_INSTALL_XSL}
        - INSTALL_SMB=${PHP_FPM_INSTALL_SMB}
        - INSTALL_IMAP=${PHP_FPM_INSTALL_IMAP}
        - INSTALL_MONGO=${PHP_FPM_INSTALL_MONGO}
        - INSTALL_AMQP=${PHP_FPM_INSTALL_AMQP}
        - INSTALL_CASSANDRA=${PHP_FPM_INSTALL_CASSANDRA}
        - INSTALL_GEARMAN=${PHP_FPM_INSTALL_GEARMAN}
        - INSTALL_MSSQL=${PHP_FPM_INSTALL_MSSQL}
        - INSTALL_BCMATH=${PHP_FPM_INSTALL_BCMATH}
        - INSTALL_GMP=${PHP_FPM_INSTALL_GMP}
        - 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_AEROSPIKE=${PHP_FPM_INSTALL_AEROSPIKE}
        - INSTALL_OCI8=${PHP_FPM_INSTALL_OCI8}
        - INSTALL_MYSQLI=${PHP_FPM_INSTALL_MYSQLI}
        - INSTALL_PGSQL=${PHP_FPM_INSTALL_PGSQL}
        - INSTALL_PG_CLIENT=${PHP_FPM_INSTALL_PG_CLIENT}
        - INSTALL_POSTGIS=${PHP_FPM_INSTALL_POSTGIS}
        - INSTALL_INTL=${PHP_FPM_INSTALL_INTL}
        - INSTALL_GHOSTSCRIPT=${PHP_FPM_INSTALL_GHOSTSCRIPT}
        - INSTALL_LDAP=${PHP_FPM_INSTALL_LDAP}
        - INSTALL_PHALCON=${PHP_FPM_INSTALL_PHALCON}
        - INSTALL_SWOOLE=${PHP_FPM_INSTALL_SWOOLE}
        - INSTALL_TAINT=${PHP_FPM_INSTALL_TAINT}
        - INSTALL_IMAGE_OPTIMIZERS=${PHP_FPM_INSTALL_IMAGE_OPTIMIZERS}
        - INSTALL_IMAGEMAGICK=${PHP_FPM_INSTALL_IMAGEMAGICK}
        - INSTALL_CALENDAR=${PHP_FPM_INSTALL_CALENDAR}
        - INSTALL_FAKETIME=${PHP_FPM_INSTALL_FAKETIME}
        - INSTALL_IONCUBE=${PHP_FPM_INSTALL_IONCUBE}
        - INSTALL_APCU=${PHP_FPM_INSTALL_APCU}
        - INSTALL_CACHETOOL=${PHP_FPM_INSTALL_CACHETOOL}
        - INSTALL_YAML=${PHP_FPM_INSTALL_YAML}
        - INSTALL_RDKAFKA=${PHP_FPM_INSTALL_RDKAFKA}
        - INSTALL_GETTEXT=${PHP_FPM_INSTALL_GETTEXT}
        - INSTALL_ADDITIONAL_LOCALES=${PHP_FPM_INSTALL_ADDITIONAL_LOCALES}
        - INSTALL_MYSQL_CLIENT=${PHP_FPM_INSTALL_MYSQL_CLIENT}
        - INSTALL_PING=${PHP_FPM_INSTALL_PING}
        - INSTALL_SSHPASS=${PHP_FPM_INSTALL_SSHPASS}
        - INSTALL_MAILPARSE=${PHP_FPM_INSTALL_MAILPARSE}
        - INSTALL_PCNTL=${PHP_FPM_INSTALL_PCNTL}
        - ADDITIONAL_LOCALES=${PHP_FPM_ADDITIONAL_LOCALES}
        - INSTALL_FFMPEG=${PHP_FPM_FFMPEG}
        - INSTALL_XHPROF=${PHP_FPM_INSTALL_XHPROF}
        - PUID=${PHP_FPM_PUID}
        - PGID=${PHP_FPM_PGID}
        - LOCALE=${PHP_FPM_DEFAULT_LOCALE}
        - http_proxy
        - https_proxy
        - no_proxy
    volumes:
      - ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini
      - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}
    expose:
      - "9000"
    extra_hosts:
      - "dockerhost:${DOCKER_HOST_IP}"
    environment:
      - PHP_IDE_CONFIG=${PHP_IDE_CONFIG}
      - DOCKER_HOST=tcp://docker-in-docker:2375
      - FAKETIME=${PHP_FPM_FAKETIME}
    networks:
      - backend
    links:
      - docker-in-docker

  ### Apache Server ########################################
  apache2:
    build:
      context: ./apache2
      args:
        - PHP_UPSTREAM_CONTAINER=${APACHE_PHP_UPSTREAM_CONTAINER}
        - PHP_UPSTREAM_PORT=${APACHE_PHP_UPSTREAM_PORT}
        - PHP_UPSTREAM_TIMEOUT=${APACHE_PHP_UPSTREAM_TIMEOUT}
        - DOCUMENT_ROOT=${APACHE_DOCUMENT_ROOT}
    volumes:
      - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}
      - ${APACHE_HOST_LOG_PATH}:/var/log/apache2
      - ${APACHE_SITES_PATH}:/etc/apache2/sites-available
    ports:
      - "${APACHE_HOST_HTTP_PORT}:8887"
    depends_on:
      - php-fpm
    networks:
      - backend

  ## NGINX Server #########################################
  nginx:
    build:
      context: ./nginx
      args:
        - CHANGE_SOURCE=${CHANGE_SOURCE}
        - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER}
        - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT}
        - http_proxy
        - https_proxy
        - no_proxy
    volumes:
      - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}
      - ${NGINX_HOST_LOG_PATH}:/var/log/nginx
      - ${NGINX_SITES_PATH}:/etc/nginx/sites-available
      - ${NGINX_SSL_PATH}:/etc/nginx/ssl
    ports:
      - "${NGINX_HOST_HTTP_PORT}:80"
      - "${NGINX_HOST_HTTPS_PORT}:443"
    links:
      - apache2
    networks:
      - backend
    depends_on:
      - apache2


vHost nginx
server {

    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    # For https
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server ipv6only=on;
    # ssl_certificate /etc/nginx/ssl/default.crt;
    # ssl_certificate_key /etc/nginx/ssl/default.key;

    set $imcontenttype	"text/html; charset=utf-8";
	set $docroot		"/var/www/public";

    server_name laradock.test;
    root /var/www/public;
    index index.php index.html index.htm;

    proxy_ignore_client_abort off;

    proxy_set_header	X-Real-IP $remote_addr;
    proxy_set_header	X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header	Host $host:80;

    set $proxyserver  http://apache2:8887;

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }

    location / {
        #try_files $uri $uri/ /index.php$is_args$args;
        proxy_pass $proxyserver;
    }
}


vHost Apache
<VirtualHost *:8887>
  ServerName laradock.test
  DocumentRoot /var/www/public/
  Options Indexes FollowSymLinks

  <Directory "/var/www/pubic/">
    AllowOverride All
    <IfVersion < 2.4>
      Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
      Require all granted
    </IfVersion>
  </Directory>

</VirtualHost>
  • Вопрос задан
  • 139 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы