【发布时间】:2019-02-01 15:32:26
【问题描述】:
我正在尝试设置 php7.1、nginx 和 laravel 5.5。连接服务器时收到错误 502。
docker-compose.yml
version: '3'
services:
# The Application
web:
image: virajkaulkar/laravel-web
ports:
- "8080:80"
volumes:
- /var/www
links:
- php
# The Application
php:
image: virajkaulkar/laravel-app
volumes:
- /var/www
env_file: '.env'
environment:
- HOST=127.0.0.1
- PORT=8080
vhost.conf
upstream phpserver {
server php:9000;
}
server {
listen 80;
listen [::]:80 default ipv6only=on;
server_name localhost;
root /var/www/public;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass phpserver;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
fastcgi_buffers 256 128k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
include fastcgi_params;
}
}
在 docker-compose.yml 上,我的 laravel 服务器在 localhost:8080 启动,webserver 也启动了。但在网络浏览器中,它给出了错误的网关异常:
connect() 在连接到上游时失败(111:连接被拒绝),客户端:172.22.0.1,服务器:localhost,请求:“GET / HTTP/1.1”,上游:“fastcgi://172.22.0.2:9000 ", 主机: "localhost:8080" –
【问题讨论】:
-
能否请您发布异常的确切日志?
-
这是我得到的确切错误:连接到上游时 connect() 失败(111:连接被拒绝),客户端:172.22.0.1,服务器:localhost,请求:“GET / HTTP/1.1 ", 上游: "fastcgi://172.22.0.2:9000", 主机: "localhost:8080" .
-
这个:
volumes: - /var/www应该是别的东西。您必须将本地目录映射到服务器上的某个目录。在继续之前,我会先改变它......
标签: docker nginx docker-compose dockerfile php-7.1