0

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

4

0 回答 0