I am trying to set up a work environment for myself. I can’t get to the server through the name specified in hosts file.
docker-compose.yml:
version: '2'
services:
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
- ./hosts:/etc/nginx/conf.d
- ./www:/var/www
- ./logs:/var/log/nginx
links:
- php
php:
build: ./images/php
links:
- mysql
volumes:
- ./www:/var/www
mysql:
image: mysql:8
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: secret
php dockerfile:
FROM php:7.1-fpm
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt mbstring mysqli pdo_mysql zip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
ADD php.ini /usr/local/etc/php/conf.d/40-custom.ini
WORKDIR /var/www
CMD ["php-fpm"]
./hosts/hello-dev.conf:
server {
server_name hello.dev;
listen 80;
index index.php;
set $MAGE_ROOT /var/www/hello.dev;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root $MAGE_ROOT;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
hosts: 127.0.0.1 hello.dev
Tell me what you can try to do in this situation? If I go to the address http://127.0.0.1 it opens the site, but I need to be able to create several configs with different names.