我有下一个docker-compose
文件:
nginx:
build: .
ports:
- "80:80"
- "443:443"
links:
- fpm
fpm:
image: php:fpm
ports:
- "9000:9000"
Dockerfile
命令列表是:
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/
我的自定义Nginx配置default.conf
文件是:
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;
}
}
docker-compose up
命令后,当我得到http://localhost/index.html
时静态页面正常工作。
但是当我打开http://localhost/index.php
时,我遇到了错误502 Bad Gateway
。
我认为问题不正确fastcgi_pass
。在我的情况下,有人可以帮我配置fastcgi_pass
吗?