使用fastcgi_pass时获取502 Bad Gateway:127.0.0.1:9000

时间:2015-04-27 18:10:55

标签: php nginx docker boot2docker docker-compose

我有下一个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吗?

0 个答案:

没有答案