reverse-proxy - 球童重写和重新分配
问题描述
我有一个棘手的案例。我想在少数情况下总是重定向。当我请求 www.myWebsite.com/toto.png 时,我想看到“toto.png”,而且当我请求 www.myWebsite.com/titi 或 www.myWebsite.com/TITI 时也想看到。在所有其他情况下,我想重定向到 www.anotherWebsite.com/。
这里我当前的配置不起作用:/
www.myWebsite.com{
tls server@myWebsite.com
root /var/www/html/
rewrite / /anotherWebsite
rewrite /titi /toto.png
redir /anotherWebsite https://www.anotherWebsite.com/
}
解决方案
我发现了这种可能性:
www.myWebsite.com, myWebsite.com {
tls server@myWebsite.com
root /var/www/html/website
rewrite {
if {path} is /titi
if {path} is /TITI
if_op or
to /toto.png
}
rewrite {
# Check for a file, then a folder
# If neither exists, we would usually issue a 404
# Instead, here we rewrite to /anotherWebsite
to {path} {path}/ /anotherWebsite
}
redir {
# /anotherWebsitewould usually still issue a 404
# So manually redir from this path if it was rewritten to
if {rewrite_uri} is /anotherWebsite
if {path} is /
if_op or
# Modify the destination and status as required
/ https://www.anotherWebsite.com
}
}
推荐阅读
- ssl - 错误:1400410B:SSL 例程:CONNECT_CR_SRVR_HELLO:Istio ingressgateway 上 https 的版本号错误
- javascript - 尝试获取对象 - 猫鼬
- tensorflow - 在张量流上乘以张量的特定单元格
- python - 使用 lambda 创建字典(内部的增量计数器)
- r - R - 将 colorQuantile() 的函数传递给 ifelse() 内的传单()的 fillColor
- android - Flutter 和 Android Studio 最大堆大小问题
- java - 如何询问用户输入并将其返回到新库存中
- python - 是否可以使用 Lab 颜色空间来分割某些颜色?
- javascript - 导入正确的文件以在 React 中使用 firebase 的实时数据库
- python - 一个看起来很奇怪的点冻结