I have next docker-compose
file:
nginx:
build: .
ports:
- "80:80"
- "443:443"
links:
- fpm
fpm:
image: php:fpm
ports:
- "9000:9000"
The Dockerfile
command list is:
FROM nginx
ADD ./index.php /usr/share/nginx/html/
# Change Nginx config here...
RUN rm /etc/nginx/conf.d/default.conf
ADD ./default.conf /etc/nginx/conf.d/
And my custom Nginx config default.conf
file is:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
error_log /var/log/nginx/localhost.error.log;
access_log /var/log/nginx/localhost.access.log;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
After docker-compose up
command the static pages work fine when I get http://localhost/index.html
.
But when I open http://localhost/index.php
I had an error 502 Bad Gateway
.
I think the problem with incorrect fastcgi_pass
. Could anybody help me config fastcgi_pass
in my case, please?