I am trying to setup php7.1, nginx and laravel 5.5. I am getting an error 502 connecting the server.
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;
}
}
On docker-compose.yml up, my laravel server get start on localhost:8080, webserver is also getting started. But in web browser it's giving bad gateway exception:
connect() failed (111: Connection refused) while connecting to upstream, client: 172.22.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://172.22.0.2:9000", host: "localhost:8080" –
volumes: - /var/www
should be something else. You must map your local directory to something on the server. I would change that first before going forward... – UnderDog