Конфигурация nginx

v752433@icloud.com 15 апреля 2022 г. 11:07

Здравствуйте, использую docker для своего приложения на laravel, проблема заключается в том что, как бы я не настраивал конфиг сервера у меня всегда отображается стартовая страница nginx

docker-compose.yml
```
version: "3.8"

services:
nginx:
image: nginx
volumes:
- ./:/var/www/
- ./_docker/nginx/conf.d/:/ect/nginx/conf.d/
ports:
- "80:80"
- "443:443"
links:
- app
depends_on:
- app
container_name: test_nginx
app:
build:
context: .
dockerfile: _docker/app/Dockerfile
volumes:
- ./:/var/www/
container_name: test_app
```

Dockerfile
```
FROM php:8.1-fpm

RUN apt-get update && apt-get install -y \
apt-utils \
libpq-dev \
libpng-dev \
libzip-dev \
zip unzip \
git && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install bcmath && \
docker-php-ext-install gd && \
docker-php-ext-install zip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/ /tmp/ /var/tmp/*

COPY ./fpm/php.ini /usr/local/etc/php/conf.d/php.ini

Install composer

ENV COMPOSER_ALLOW_SUPERUSER=1
RUN curl -sS https://getcomposer.org/installer | php -- \
--filename=composer \
--install-dir=/usr/local/bin

WORKDIR /var/www

CMD ["php-fpm"]
```

nginx.conf
```
server {
listen 80;
listen [::]:80;
server_name _;
root /var/www/public;
index index.php index.html index.htm index.nginx-debian.html;
error_log /var/log/nginx/error.log;
location / {
try_files $uri /index.php;
}

location ~ \.php$ {
   try_files $uri =404;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_pass app:9000;
   fastcgi_index index.php;
   include fastcgi_params;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   fastcgi_param PATH_INFO $fastcgi_path_info;
}

}
```