So, in my build, I have three containers - one for db, second one is php-apache for displaying dynamic content, and third is nginx for displaying static content and redirecting dynamic requests to the apache container. Here is my code: docker-compose.yml
version: "3.8"
services:
db:
image: "mysql:latest"
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: 1
volumes:
- ./mysql:/docker-entrypoint-initdb.d
ports:
- "3306"
apache:
build:
context: ./apache
volumes:
- ./php/dynamic:/var/www/html/
ports:
- 81:80
nginx:
build:
context: ./nginx
ports:
- 82:80
volumes:
- ./php/static:/var/www/html/
links:
- apache
Here is my nginx.conf file, which I'm putting inside the container.
server {
listen 0.0.0.0:80;
root /var/www/html;
location / {
index index.php index.html;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass apache:81;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
}
While trying to test web socket, by connecting to the: http://localhost:82/dynamic1.php I'm getting bad gateway error, and in console:
[error] 30#30: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.20.0.1, server: , request: "GET /dynamic1.php HTTP/1.1", upstream: "fastcgi://172.20.0.2:81", host: "localhost:82"