[MacPorts] #68621: Two nginx problems: 1. try_files will add "html" to the search path 2. 403 even though all permissions are set properly.

MacPorts noreply at macports.org
Thu Nov 2 07:22:23 UTC 2023


#68621: Two nginx problems: 1. try_files will add "html" to the search path 2.  403
even though all permissions are set properly.
---------------------+--------------------
 Reporter:  qiulang  |      Owner:  (none)
     Type:  defect   |     Status:  new
 Priority:  Normal   |  Milestone:
Component:  ports    |    Version:
 Keywords:  nginx    |       Port:
---------------------+--------------------
 I have encountered 2 nginx problems that I feel they are bugs although I
 am not 100% sure.

 Using the following nginx.conf to illustrate my problems. I host two web
 apps in one domain but on different paths, one url uses "/" and the other
 url uses **"/za"**. But both web apps set their static files' base path to
 "/", not with a prefix, so I use a {{{try_files}}} in the 1st location
 rule to let nginx search the 2nd location for the webapp **za** related
 stuff.

 From the error.log I found that nginx will search the path from
 {{{/opt/local/html}}} so to make my {{{try_files}}} statement work I have
 to write {{{/../za$uri}}} to skip the {{{html}}} path.

 But the problem is when I use {{{nginx -V}}} to check the prefix it is
 {{{/opt/local}}} not {{{/opt/local/html}}} and for the first location rule
 {{{share/nginx/html/dist/}}}, it can correctly search
 {{{/opt/local/share/nginx/html/dist/}}} not
 {{{/opt/local/html/share/nginx/html/dist/}}}.

 Besides, {{{/opt/local/html}}} does not exist so where does {{{html}}}
 part come from?





 {{{
 server {
         ...

         location / {
             root   share/nginx/html/dist/;
             #root   /Users/langqiu/myapp/dist;
             try_files $uri $uri/ /../za$uri; #b/c there is no html folder
         }

         location /za/ {
             alias   share/nginx/html/za/;
         }
 }
 }}}

 My second problem is about file permission as show in in the rule {{{#root
 /Users/langqiu/myapp/dist;}}}
 I have run chomd 755 to {{{/Users/langqiu/myapp/dist}}} (even 777) to make
 that folder can be read but I still get 403 error.

 Only if I copy the files into {{{/opt/local/share/nginx/html/}}} folder I
 won't get 403.

-- 
Ticket URL: <https://trac.macports.org/ticket/68621>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list