403 Forbidden after I close Docker: directory index of "/etc/nginx/html/" is forbidden
I run the one liner, then add sample data and run setup:upgrade. the env works pefectly.
If I then stop the environment, quit docker, then open docker again and run the environment, I get 403 forbidden at magento.test. Below is what is generated in the nginx CLI container when I try to visit magento.test:
2022/11/11 15:29:12 [error] 29#29: *1 directory index of "/etc/nginx/html/" is forbidden, client: 172.18.0.1, server: , request: "GET / HTTP/2.0", host: "magento.test"
172.18.0.1 - - [11/Nov/2022:15:29:12 +0000] "GET / HTTP/2.0" 403 555 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" "-"
Am I doing something wrong? How can i spin down and spin back up the environment without getting this error every time?
Not sure if this has to do with anything, but I also notice when I try to restart the env, the phpmyadmin container gets hung up trying to start, shows this:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.7. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.7. Set the 'ServerName' directive globally to suppress this message
[Thu Nov 10 19:07:10.995905 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.53 (Debian) PHP/8.0.19 configured -- resuming normal operations
[Thu Nov 10 19:07:10.995966 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
[Thu Nov 10 21:22:09.700588 2022] [mpm_prefork:notice] [pid 1] AH00170: caught SIGWINCH, shutting down gracefully
I am having the same issue. I could install one project but when trying to install a second one (both from an existing project) I cannot access it. When checking docker-desktop logs got the following:
2022/11/13 22:12:37 [info] 29#29: *3 SSL_do_handshake() failed (SSL: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown:SSL alert number 46) while SSL handshaking, client: 172.21.0.1, server: 0.0.0.0:8443
2022/11/13 22:12:37 [error] 29#29: *4 directory index of "/etc/nginx/html/" is forbidden, client: 172.21.0.1, server: , request: "GET / HTTP/2.0", host: "apac.localhost"
172.21.0.1 - - [13/Nov/2022:22:12:37 +0000] "GET / HTTP/2.0" 403 555 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" "-"
any solution?
SO: ubuntu 22.04
I added a help wanted tag to this issue, as I don't run Linux. If anyone has a fix for this, I'll gladly take it in!
@Maxi-07 you need to delete all mess
- In your folder use this
bin/removeallyou must delete src and cache docker files and containers - Than you must
rf -rf magentofolder that you need to delete all files. - Setup correct credentials, your error on setup depends on not correct setup, please check credentials
go tocd ~/.composernano auth.jsonAnd try to check do you use here credentials from this portal https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html here https://marketplace.magento.com/ you need to create an Access Keys and than use it in ~/.composer/auth.json
This must resolve problems with html folder.
I have the same problem. All was working fine until Docker was restarted on host reboot.
Docker Log Entry:-
[error] 29#29: *2 directory index of "/etc/nginx/html/" is forbidden, client: 172.18.0.1, server: , request: "GET / HTTP/2.0", host: "magento.test"
OS: macOS Ventura 13.0 (22A380) Docker Desktop Version 4.14.1 (91661)
Update Steps
- Removed all traces of broken project.
- Restarted a new project from one liner automated.
- Installed successfully.
- Stopped all containers
- Closed Docker Desktop
- Re-open Docker Desktop
- All containers spin up (except phpmyadmin for some reason??).
- NGINX 403 Forbidden error is thrown at "magento.test"
This is a base install without sample data or any changes to core. Literally vanilla install.
@stu583 what is the result of running either of these commands?
bin/fixowns
bin/fixperms
I can't replicate this. My only guess is that you are mounting the project outside of the default filesystem locations defined in Docker Desktop > Resources > File Sharing:

I'm facing the same issue. Running ./bin/fixowns and ./binfixperms does not resolve the issue for me. My Docker Desktop file sharing configuration is the same as Mark's above too.
I am able to access PhpMyAdmin if I switch to http instead of https. This made me think Chrome might have been trying to protect me from an invalid cert but I get the same behaviour in Firefox and Safari.

The Magento application is installed. I can see all of the files in the container, run bin/magento commands from inside the container, and connect to the database etc.
MacOS 13.0 Docker version 20.10.21, build baeda1f Docker Compose version v2.12.2
EDIT: Forcing Chrome to accept self-signed certs from localhost didn't solve this either.

I resolved my issue by ensuring the nginx.conf.sample file was properly mounted inside the container. I'd commented this line out previously so un-commenting it and restarting the containers fixed this issue for me 🙂
Ok thanks for the update. I haven't heard back on this, so closing it out. If it's still an issue, please let me know and I can reopen it.
I resolved my issue by ensuring the
nginx.conf.samplefile was properly mounted inside the container. I'd commented this line out previously so un-commenting it and restarting the containers fixed this issue for me 🙂
Still working, thanks for the fix!
The issue was fixed when the compose.yaml was updated with compose.dev-linux.yaml content. I believe the above mentioned the same thing but added it here if anyone didn't clearly understand it.
So the final content of compose.yaml file app service content will be look like the below:
app:
image: markoshust/magento-nginx:1.24-0
ports:
- "80:8000"
- "443:8443"
volumes: &appvolumes
- ~/.composer:/var/www/.composer:cached
- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
- ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
# compose.dev-linux.yaml added lines start
- ./src/nginx.conf.sample:/var/www/html/nginx.conf:cached
- ./src:/var/www/html:cached
# compose.dev-linux.yaml added lines end
- appdata:/var/www/html
- sockdata:/sock
- ssldata:/etc/nginx/certs
#extra_hosts: &appextrahosts
## Selenium support, replace "magento.test" with URL of your site
#- "magento.test:172.17.0.1"
## Linux, uncomment for Xdebug capabilities:
#- "host.docker.internal:host-gateway"
As I noticed, this issue https://github.com/markshust/docker-magento/issues/203 is duplicated with the same error.
Thanks for the fix!
Cheers!
Does anyone have exact steps to get this working on linux from start to finish? I managed it by randomly adding and removed lines from yaml files, starting and stopping containers and deleted src dir and eventually got it working. But I have no idea how to recreate steps.
@DomPixie there is documentation for Linux at https://github.com/markshust/docker-magento?tab=readme-ov-file#linux
I faced the same issue and for me the following worked:
Even though the following setting was correct for: compose.dev.yaml
- ./src/nginx.conf.sample:/var/www/html/nginx.conf:cached
The file was still present inside the container as sample so had to update it.
Fix:
mv nginx.conf.sample nginx.conf- confirm the nginx conf file is correct:
ls -larth | grep 'nginx'