nginx - 如何在 nginx 中动态匹配 URL 位置
问题描述
我是 nginx 的新手,我试图阻止它返回 403 的特定 url。当 url 为:http://mysite.domain.com/user/test.test/files/person 时,我需要返回 403。 jpg?=下载. 但是这个 url --> location /user/([a-zA-Z.]+.?$)/files/ 不起作用。请帮忙。:(
server {
listen 80;
server_name localhost;
error_page 403 /403.html;
location = /403.html {
root /usr/share/nginx/html/;
internal;
}
location /test {
return 502;
}
location /user/([a-zA-Z.]+\.?$)/files/ {
return 403;
}
location /user/files/ {
return 503;
}
location / {
return 500;
}
}
解决方案
推荐阅读
- powershell - 如何在 PowerShell Get-ChildItem 中的通配符模式中使用方括号?
- c++ - 我发送了一个 websocket 包,但服务器只回答 400
- mysql - 带有子查询的 MySQL 嵌套 Select 语句
- python - 如何使用十六进制值在 matplotlib 中创建自定义颜色名称?
- jenkins - 如何在 2 个不同的变量中传递来自 jenkins 脚本的 2 个结果
- python - SQLAlchemy 多个连接到单个表
- vb.net - 有没有办法在 VB.net 中将像素坐标转换为笛卡尔坐标
- azure - azure api manager 步骤为自定义域创建 pfx 文件
- c# - 是否可以将 dotnet core 控制台应用程序用作库
- python - Django如何将选择列表传递给自定义选择小部件