Problem with Laravel, once launched with PHP-FPM and NGINX no file is accessible except index.php.
Once my application is launched all the application is executed successfully except that the CSS and my JS scripts present in the public folder of Laravel are not accessible and therefore it is not applied on the application.
My application is deployed with Docker and works like this:
A container for the laravel application launched with PHP-FPM
A NGINX container as web server
A Mysql container
File docker-compose.yml :
version: '3'
services:
#PHP Service
app-dockerTag:
image: appName
build:
context: .
dockerfile: Dockerfile
container_name: app-dockerTag
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www/html/
#Nginx Service
webserver-dockerTag:
image: nginx:alpine
container_name: webserver-dockerTag
restart: unless-stopped
tty: true
ports:
- "portApp:80"
volumes:
- ./:/var/www
- ./build/nginx/:/etc/nginx/conf.d/
#MySQL Service
db:
image: mysql:5.7.22
container_name: db
restart: unless-stopped
tty: true
ports:
- dbPort:dbPort
volumes:
- ./mysql/:/docker-entrypoint-initdb.d
- ./api:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=dbRootPassword
- MYSQL_DATABASE=dbDatabase
- MYSQL_USER=dbUsername
- MYSQL_PASSWORD=dbPassword
- MYSQL_HOST_ROOT=%
- MYSQL_TCP_PORT=dbPort
File conf nginx :
server {
listen 80;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app-dockerTag:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
File DockerFiles for laravel :
FROM php:7.3-fpm
# Set working directory
WORKDIR /var/www/html
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
mariadb-client \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
libzip-dev
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY composer.json composer.json
#COPY composer.lock composer.lock /var/www/
COPY . .
RUN composer install
RUN composer dump-autoload
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www/html
# Copy existing application directory permissions
COPY --chown=www:www . /var/www/html
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm", "-F"]
My problem does not appear when I work locally with php artisan serve and once docked, all files normally accessible in public generate 404 errors.
Related
I'm making a cURL request
curl -X 'POST' \
'http://localhost:8013/api/superheros' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name": "Clark Kent",
"slug": "supermman",
"featured": true,
"createdAt": "2021-10-11T11:48:22.366Z"
}'
to an API endpoint on my local above. I receive a 502 bad gateway error.
I'm using Docker for all intents and purposes.
docker-compose.yml
version: '3'
services:
#PHP Service
app1:
build:
context: .
dockerfile: Dockerfile
image: digitalocean.com/php
container_name: app1
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app1
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginx Service
webserver1:
image: nginx:alpine
container_name: webserver1
restart: unless-stopped
tty: true
ports:
- "8013:80"
- "443:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
#MySQL Service
db1:
image: mysql:5.7.22
container_name: db1
restart: unless-stopped
tty: true
ports:
- "3318:3306"
environment:
MYSQL_DATABASE: rest_api
MYSQL_ROOT_PASSWORD: password
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
Dockerfile
FROM php:7.4-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
libzip-dev \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql zip exif pcntl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install gd
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
app.conf
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
I've read people saying that PHP-FPM isn't running but my Dockerfile clearly uses it. Are you able to offer some clues?
You could try to pass arguments to php-fpm in your Dockerfile as below, and make sure 9000 port is configured in local.ini
CMD ["php-fpm", "-F", "-y", "/usr/local/etc/php/conf.d/local.ini"]
-F force php-fpm running in foreground
-y sepcify the config path
After Dockerfile modified, you need to run docker-compose build to rebuild docker image
I'm fairly new to docker and trying to understand a few things about it.
Here's my scenario, I want to have my application in it's own image and then use docker compose to blend it together (since I've read that you shouldn't be mixing nginx & php together, according to best practices).
I made a small PoC and so far it's not working, but I'm hoping it's just more me missing something important.
when I type in docker-compose up, everything loads but nginx seems to not know anything about the php service as it just loads the default nginx page and trying to access any php code from the php service gives me a 404.
this is what my compose yaml file looks like:
services:
web:
image: nginx:mainline-alpine
depends_on:
- php
ports:
- "80:80"
volumes_from:
- php
volumes:
- ./nginx.conf:/etc/nginx/conf.d/nginx.conf
php:
image: myprivaterepo.com/poc/php-test:latest
volumes:
- ./app:/app
and the dockerfile is currently simply:
FROM php:fpm
WORKDIR /app
COPY . .
CMD ["php-fpm"]
the idea is the php service has the php code and the web service would be able to access the files and it'd work.
I'm fairly sure I'm just missing something important but since I'm still new to this, I'm not sure what that is.
The goal would be to have the application all packed up and just spin up without a lot of hassle.
What I do for docker is
First Dockerfile with everything I need; change docker file as you desire.
FROM php:7.2-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
mariadb-client \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
Create mysql folder in root and my.cnf in that directory with the following content
[mysqld]
general_log = 1
general_log_file = /var/lib/mysql/general.log
Now create nginx/conf.d folder with app.conf with the following
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
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;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
Now just create php/local.ini folder and leave it as it is for now
Now create docker-compose.yml file with following
version: "3"
services:
app:
build:
context: .
dockerfile: Dockerfile
image: digitalocean.com/php
container_name: app-docker
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini`
networks:
- projectdocker
webserver:
image: nginx:alpine
container_name: nginx-docker
restart: unless-stopped
tty: true
ports:
- "8081:80"
- "444:444"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- projectdocker
db:
image: mysql:5.7.22
ports:
- "6001:3306"
container_name: db-docker
restart: unless-stopped
tty: true
environment:
MYSQL_DATABASE: docker
MYSQL_ROOT_PASSWORD: root
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- projectdocker
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- "7000:80"
links:
- db:db-docker
environment:
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
networks:
- projectdocker
volumes:
dbdata:
driver: local
networks:
projectdocker:
driver: bridge
now run docker-compose up -d –build
link to localhost will be http://localhost:8081/
link to phpmyadmin will be http://localhost:7000/
I am trying to run Laravel 8 (with the database!) in Google Cloud. Deployment is done via Cloud Run with GitHub CI Trigger
What I have done so far:
I created all necessary Docker files for building the Docker image and container like the Dockerfile and docker-composer.yml in my apps doc root.
Because my app needs a backend and a database, I created an nginx.conf-file and an int_db.sql file, to seed the database.
Dockerfile
FROM php:7.4-fpm
# Arguments defined in docker-compose.yml
ARG user=hannes
ARG uid=1002
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
# Get the latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create system user to run Composer and Artisan Commands
#RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN useradd -u 1002 -G www-data,root -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user
# Set working directory
WORKDIR /var/www
USER $user
docker-compose.yml
version: "3.7"
services:
app:
build:
args:
user: hannes
uid: 1002
context: ./
dockerfile: Dockerfile
image: feedbackapp
ports:
- 8080
environment:
# /run/docs/reference/container-contract
PORT: ${PORT:-8080}
K_SERVICE: feedbackapp
K_REVISION: 0
K_CONFIGURATION: feedbackapp
container_name: feedbackapp-container
restart: unless-stopped
working_dir: /var/www/
volumes:
- ./:/var/www
networks:
- feedbackapp
db:
image: mysql:5.7
container_name: feedbackapp-db
restart: unless-stopped
environment:
MYSQL_DATABASE: homestead
MYSQL_ROOT_PASSWORD: homestead
MYSQL_PASSWORD: secret
MYSQL_USER: homestead
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- ./docker-compose/mysql:/docker-entrypoint-initdb.d
networks:
- feedbackapp
nginx:
image: nginx:alpine
container_name: feedbackapp-nginx
restart: unless-stopped
ports:
- 8000:80
volumes:
- ./:/var/www
- ./docker-compose/nginx:/etc/nginx/conf.d/
networks:
- feedbackapp
networks:
feedbackapp:
driver: bridge
feedbackapp.conf
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
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;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
In my local Docker environment, the Laravel 8 app gets successfully built and is working well, if i request the app via http://localhost:8000/.
So I created a Cloud Run Service in Google Cloud with a CI trigger of my GitHub Repo. So every time I push my branch, my Cloud Run Service is triggered and builds my app.
The build is finished successfully in Cloud Build.
Problem: if an open the apps link, I get a 503 Service Unavailable error
Web
Network Status
What the log tells me:
Log
Any help is much appreciated. Stay safe.
There is a big confusion.
Cloud Run needs Dockerfile and that should expose proper HTTP service on port 8080.
So docker-compose is not used by Cloud Run.
Make sure for Cloud Run that your Dockerfile expose port 8080.
make sure your container also has the HTTP server and the PHP executables.
What I see at first is that your Dockerfile doesn't have a webserver and doesn't expose port 8080.
docker-compose is only for local development.
I think I have a link problem I have an error in my application I have a 502 bad gateway error,
and in the app log
[error] 6 # 6: * 1 connect () failed (111: Connection refused) while connecting to upstream, client: 172.18.0.5, server: laravel-api.art, request: "GET / HTTP / 1.1", upstream: "fastcgi: //172.18.0.19: 9000", host: "laravel-api.art" 172.18.0.5
here is my nginx config file
server {
listen 80;
server_name laravel-api.art;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass laravel-api:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
my Dockerfile
``` FROM php:7.4-fpm
COPY composer.lock composer.json /var/www/
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libzip-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql zip exif pcntl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install gd
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy application folder
COPY . /var/www
# Copy existing permissions from folder to docker
COPY --chown=www:www . /var/www
RUN chown -R www-data:www-data /var/www
# change current user to www
USER www
EXPOSE 9000
CMD ["php-fpm"]
# production environment
FROM nginx:stable-alpine
RUN rm /etc/nginx/conf.d/default.conf
#COPY nginx/nginx.conf /etc/nginx/conf.d
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]```
and my docker compose
I use an external reverse proxy
```
version: "3.7"
services:
#PHP Service
laravel-api:
build:
context: .
dockerfile: Dockerfile
container_name: ${containerNameServer}
restart: unless-stopped
tty: true
working_dir: /var/www
volumes:
- ./:/var/www
- ./docker-files/php/local.ini:/usr/local/etc/php/conf.d/local.ini
environment:
VIRTUAL_HOST: ${VIRTUAL_HOST_SERVER},${VIRTUAL_HOST_WWW_SERVER}
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST_SERVER}
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
volumes:
laravel-api:
networks:
default:
external:
name: webproxy
```
for information it works with other nodejs / vuejs application but this is my first laravel php-fpm application
So, after a lot of trying i managed to get my Laravel 5.6 app to run via docker. I am creating the image and storing it on Amazon ECR. Then via docker-compose i am loading the Laravel, Nginx and some others.
Everything works perfectly except for one thing. Everything related to assets like css and js are not loaded (404).
I tried loading them with '/' in front, i tried via the assets() function, to no avail.
So, here are the files i have used:
Dockerfile of Laravel app:
FROM php:7.1.15-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client zip unzip git libjpeg62-turbo-dev libpng12-dev libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install gd mcrypt pdo_mysql \
&& 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
COPY php-fpm.conf /etc/php-fpm.conf
COPY www.conf /etc/php-fpm.d/www.conf
WORKDIR /var/www
COPY . /var/www
RUN composer update
RUN chown -R www-data: /var/www
This image is built fine and stored in Amazon.
The docker-compose file:
version: '2'
services:
# The Laravel Application
app:
image: URL_TO_IMAGE-WORKS
restart: always
working_dir: /var/www
volumes:
- ./storage/app:/var/www/storage/app
- ./storage/logs:/var/www/storage/logs
- "./php-fpm.conf:/etc/php-fpm.conf"
- "./www.conf:/etc/php-fpm.d/www.conf"
links:
- database
environment:
- "DB_PORT=3306"
- "DB_HOST=database"
#The Nginx server
proxy:
build: server
working_dir: /var/www
restart: always
volumes_from:
- app
ports:
- "80:80"
database:
image: mysql:5.7.22
volumes:
- ./mysqldata_2:/var/lib/mysql
restart: always
environment:
- "MYSQL_ROOT_PASSWORD=secret"
- "MYSQL_DATABASE=secret"
- "MYSQL_PASSWORD=secret"
- "MYSQL_USER=secret"
ports:
- "33061:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- database
ports:
- '8080:80'
restart: always
environment:
PMA_HOST: database
PMA_PORT: 3306
elk:
image: sebp/elk
ports:
- "5601:5601"
- "9200:9200"
- "5044:5044"
The NGINX Docker file is:
FROM nginx:alpine
RUN rm /etc/nginx/conf.d/*
COPY proxy.conf /etc/nginx/conf.d
The proxy.conf used by NGINX:
server {
listen 80;
server_name admin.mydomain.com;
include /etc/nginx/mime.types;
index index.php server.php;
root /var/www/public;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
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;
}
}
So, after everything starts up nicely, and i navigate to the admin.mydomain.com functionality wise its ok, but neither css nor js files load.
I tried a lot of different settings, both on the docker image and the nginx settings to no avail. Any insights would be highly appreciated!
Note: should you need any extra infos, please let me know
I had this problem.
I linked the storage (php artisan storage:link) locally, and made sure I could locate the files through ls while in the container.
I made sure my vhost.conf (using apache) was following symlinks.
I checked the at mod_rewrite was enabled (a2enmod rewrite) at the end of the dockerfile.
Nginx (proxy docker) serve directly the static content without use php script (app docker).
The docker-compose file must define the volume parameter for proxy service :
proxy:
build: server
working_dir: /var/www
restart: always
# Here the volume defined
volumes:
- ./:/var/www
ports:
- "80:80"
complete working without DB :
docker-compose.yml :
version: '3.4'
services:
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www:cached
web:
build:
context: ./
dockerfile: web.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
ports:
- 81:81
app.dockerfile :
FROM php:7.1.3-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql
web.dockerfile :
FROM nginx:1.10
ADD vhost.conf /etc/nginx/conf.d/default.conf
vhost.conf :
server {
listen 81;
index index.php server.php index.html;
root /var/www/public;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
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;
}
}