Answers:
您可以将proxy_pass绑定到您喜欢的路径,就像这样
location = / {
    proxy_pass http://localhost:9999/;
}
这样可以确保没有其他路径可以通过 /
要么
您可以将这种语法仅用于要匹配的子目录
location ^~ /subdir {
     alias /var/www/site/subdir;
}
location / {
    proxy_pass http://localhost:9999/ ;
}
在^~该子目录相匹配,然后停止搜索,因此/将不会被执行。在这里描述。
alias代替使用root
                    ^~吗?我不知道该怎么做。我尝试阅读您发送的链接,但仍然无法获取。如果最长匹配前缀位置具有“ ^〜”修饰符,则不检查正则表达式。