如何从 NGINX 提供 root 之外的相对源 url

How to serve relative source urls outside root from NGINX

这看起来很基础,但我无法解决这个问题。 我希望 NGINX 在当前根之外提供源 URL,基本上从 ../

开始

这是我的目录

common
root (NGINX root)
    ->index.html (NGINX default index)
    common (another common folder)

我希望能够服务

src="../common/whatever" /*outer common folder*/
src="./common" /*inner common folder; Cannot change unfortunately*/

如您所见,简单的 location /common 行不通。

这是我当前的 NGINX 配置文件,

server
{

  listen 83 default_server;
  listen [::]:83 default_server ipv6only=on;

  root C:/www/root;
  index index.html index.htm;

  #This does not work for inner /common folder
  location /common {
    root C:/www;
    try_files $uri /index.html;
  }

  location / {
    try_files $uri /index.html;
  }
}

也许你可以反过来做:

root/
  common/*
  site/
  site/common/*

然后做类似

的事情
 location /common {
   try_files site/$uri $uri ...;
 }

等...这给你 $root/site/common/FILE, $root/common/FILE....