我有一个网页,位于example.com/app
。
有没有办法拒绝直接访问example.com/app
并仅允许通过app.example.com
NGINX 访问?
答案1
在您的example.com
server
区块中location ~ app { deny all; }
(或类似区块中):
server {
server_name example.com;
location ~ api { deny all; }
<configuration for example.com>
}
server {
server_name api.example.com;
<configuration for api.example.com>
}