I am using the following file copied at /etc/nginx/conf.d/default.conf
server {
listen 80;
root /var/www/html/public;
index index.php index.htm index.html;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
location ~ \.php$ {
return 404;
}
}
It is giving me the following error in log
*7 directory index of "/var/www/html/" is forbidden, client: 172.17.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost:8080"
Trying to debug but no clue.
My files are under www-data:www-data
I am using a docker image from php:7.4-fpm if it is related.
FROM php:7.4-fpm
WORKDIR /var/www/html
RUN export DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y nginx procps
COPY infrastructure/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY infrastructure/entrypoint.sh /etc/entrypoint.sh
EXPOSE 80
ENTRYPOINT ["sh", "/etc/entrypoint.sh"]
Thanks for help.
docker run -p 8080:80 -v /path/to/project:/var/www/html test-php
– Raheells -al
you posted is done from your host or inside your container ? – Michée Lengronneindex.html
file in/var/www/html
. The configuration file in your question sets the root to/var/www/html/public
which means that it's not the configuration that Nginx is using. Usenginx -T
(uppercaseT
) to view the entire configuration that Nginx is reading. – Richard Smith