Access to Nginx on mac is 403 Forbidden

Asked 2 years ago, Updated 2 years ago, 61 views

Access to Nginx installed on mac via brew will show 403 Forbidden.

Environment
OS Capitan
Nginx 1.8.1

Access to Nginx is at localhost:8080.

nginx.conf is as follows.(Remains the default.comment lines have been deleted.)

worker_processes1;
events {
    worker_connections1024;
}

US>http{
    include mime.types;
    default_type application/octet-stream;

    sendfile on;
    keepalive_timeout65;

    server{
        listen8080;
        server_name localhost;

        location / {
            roottml;
            index index.html index.htm;
        }

        error_page500502503504/50x.html;
        location=/50x.html{
            roottml;
        }
    }
}

I don't know why it's 403.
The destination folder html is as follows:
lrwxr-xr-x1 My admin 162 24 16:20 html->../../var/www
The folder www has the following files:
-rwxr-xr-x1 My admin 537 126 23:39 50x.html
-rwxr-xr-x1 My admin 612 12 26 23:39 index.html
r I think I can read it because I have permission. Is there any problem you can think of?

macos nginx

2022-09-30 17:09

2 Answers

serverfault had a similar question.
The hierarchy above the folder where the files are actually located must also be accessible to the nobody.
There seems to be an error. (I just need to create an environment and check it, but I can't check it on the go...)

Below is a quote.

What are the permissions on /Users/me, /Users/me/Documents and/Users/me/Documents/workspace? All of the folders in the tree need to be ready by the nobody user.


2022-09-30 17:09

There seems to be a parameter to enable or disable symbolic links.
I found an article related to nginx's official website.

Syntax:disable_simlinks off;
disable_simlinks on | if_not_owner [from=part];
Default:
disable_simlinks off;
Context: http, server, location

Determines how symbolic links should be created when opening files:

I think the above settings are enabled because this corresponding configuration resolves the problem.

I added the root directive in server{} and explicitly added the path up to html_2, and it worked.


2022-09-30 17:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.