I was reviewing and old project done in 2020, it's a website running on LEMP stack in a Docker container, the problem is: nginx won't serve pages. It looks like it takes too long to load pages but I don't really know what is going on since there's no errors in errors.log
.
here is the docker-compose.yml
version: "3"
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: instagram
MYSQL_USER: root
MYSQL_PASSWORD: root
volumes:
- ./db:/var/lib/mysql
adminer:
image: adminer
restart: always
ports:
- 8080:8080
phpfpm:
image: bitnami/php-fpm:7.2-debian-10
ports:
- 9000:9000
volumes:
- ./app:/usr/share/nginx/html
- ./php/php.ini:/opt/bitnami/php/etc/php.ini
nginx:
image: nginx:1.16.1-alpine
ports:
- 80:80
- 443:443
volumes:
- ./app:/usr/share/nginx/html
- ./nginx/conf.d/:/etc/nginx/conf.d/
- ./nginx/logs/:/var/log/nginx/
here is the nginx default.conf
file as well
server {
listen 80 default_server;
listen [::]:80 ipv6only=on default_server;
server_name ltw_local;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /usr/share/nginx/html;
client_max_body_size 256m;
location / {
try_files $uri $uri/ /index.php;
# kill cache (just for development)
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass phpfpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
I thought it could've been a port problem but i have no other process running on port 80, this is the result of netstat -plant | grep 80
:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1/nginx: master pro
tcp 0 0 :::80 :::* LISTEN 1/nginx: master pro
I also tried to use the latest image of nginx instead of the 1.16.1 but the same problem occurs.
If you want you can also clone the entire repo
(P.S. if you're on Windows and you get an error relative to the lower_case_table_names
parameter in the mysql image you'll need to run fsutil file setCaseSensitiveInfo ./ enable
inside the ./db
folder, this is due to the introduction of wsl2 since docker 2.4)
.
Let me know if you need more informations.
thank you for your time!