docker-magento icon indicating copy to clipboard operation
docker-magento copied to clipboard

403 Forbidden after I close Docker: directory index of "/etc/nginx/html/" is forbidden

Open ross-peterson opened this issue 4 years ago • 13 comments

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

ross-peterson avatar Nov 11 '22 15:11 ross-peterson

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

Maxi-07 avatar Nov 13 '22 22:11 Maxi-07

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!

markshust avatar Nov 20 '22 15:11 markshust

@Maxi-07 you need to delete all mess

  1. In your folder use this bin/removeall you must delete src and cache docker files and containers
  2. Than you must rf -rf magento folder that you need to delete all files.
  3. Setup correct credentials, your error on setup depends on not correct setup, please check credentials
    go to cd ~/.composer nano auth.json And 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.

tbunitrade avatar Nov 29 '22 12:11 tbunitrade

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

  1. Removed all traces of broken project.
  2. Restarted a new project from one liner automated.
  3. Installed successfully.
  4. Stopped all containers
  5. Closed Docker Desktop
  6. Re-open Docker Desktop
  7. All containers spin up (except phpmyadmin for some reason??).
  8. 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 avatar Nov 30 '22 21:11 stu583

@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: Screenshot 2022-12-04 at 8 35 51 AM

markshust avatar Dec 04 '22 13:12 markshust

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.

Screenshot 2022-12-22 at 15 41 23

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.

Screenshot 2022-12-22 at 15 46 02

pykettk avatar Dec 22 '22 15:12 pykettk

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 🙂

pykettk avatar Dec 22 '22 16:12 pykettk

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.

markshust avatar Dec 28 '22 12:12 markshust

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 🙂

Still working, thanks for the fix!

magenizr avatar Nov 16 '23 02:11 magenizr

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!

dazimax avatar Nov 09 '24 16:11 dazimax

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 avatar Mar 27 '25 16:03 DomPixie

@DomPixie there is documentation for Linux at https://github.com/markshust/docker-magento?tab=readme-ov-file#linux

markshust avatar Apr 07 '25 15:04 markshust

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:

  1. mv nginx.conf.sample nginx.conf
  2. confirm the nginx conf file is correct: ls -larth | grep 'nginx'

balvesh avatar Jun 12 '25 16:06 balvesh