Answer the question
In order to leave comments, you need to log in
How to set up nginx in docker-compose?
Hello
, I can’t understand why, but the site configured via docker-compose
version: '3.1'
services:
nginx:
image: nginx:latest
ports:
- 80:80
- 443:443
volumes:
- ./hosts/mysite.local.conf :/etc/nginx/conf.d/mysite.local.conf
- ./www:/var/www
- ./www:/usr/share/nginx
- ./logs:/var/log/nginx
depends_on:
- php
settings ./hosts/mysite.local.conf
server {
server_name mysite.local www.mysite.local;
root /var/www/html/public;
listen 80;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
mysite.local does not open, everything is registered in the hosts, the service starts, 127.0.0.1 shows the nginx start page, there is a suspicion that there is a problem with the nginx config or with the docker-compose settings?
Answer the question
In order to leave comments, you need to log in
Read what is DNS.
Think about how your browser should know the IP address of mysite.local
Register in hosts
127.0.0.1 mysite.local
Check.
well, I played around here ..
if I take your docker-compose , then it doesn’t take off from me, swears at an incorrect bind, change the version from 3.1 to 2 - and you’re done, everything went fine.
further, of course, I assume that everything is correct in your structure, but we don’t see the whole config here, therefore -
do you definitely have everything you need in www/? ./www/html/public/ and so on.
What's in the nginx logs?
I will add. about the version - by, it was my jamb, everything takes off on your version too.
then only look at the logs of nginx itself - otherwise it's hard to guess.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question