老哥们 求助一个 nginx 的技术问题 怎么在反代替换链接数据

2022-01-10 21:04:44 +08:00
 LIBQ

具体需求如图 怎么将 URL 中的aaabcd更改为aaabbd

2011 次点击
所在节点    NGINX
8 条回复
daimaosix
2022-01-10 21:09:20 +08:00
location /aaabcd {
proxy_pass 源站 /aaabbd;
}

这样不行吗?
LIBQ
2022-01-10 21:13:36 +08:00
@daimaosix 这个是一大串里面节选的 并不是目录
sparktour
2022-01-10 22:05:46 +08:00
nginx 的 sub_filter 可以做到替换源站的字符串,参考 https://www.nginx.com/resources/wiki/modules/substitutions/
cattyhouse
2022-01-11 05:42:05 +08:00
location / {
# 网站镜像
# 此时 root /var/www/html; 的内容不会再显示
# limit_req zone=mylimit; # 启用限制
# 先定义好要 mirror 的网站以及自己的网站
set $upstream_server http://mirror_domain.tld;
set $upstream_domain mirror_domain.tld;
set $mydomain example.com;
# use variable to avoid resoling failure that leads to start nginx failure
# refer: https://sandro-keil.de/blog/let-nginx-start-if-upstream-host-is-unavailable-or-down/

sub_filter_once off;
sub_filter_types *;

sub_filter $upstream_domain $mydomain;
proxy_set_header Referer $upstream_server;
proxy_set_header Host $upstream_domain;
proxy_pass $upstream_server;
}
swcat
2022-01-11 09:38:44 +08:00
openresty 解千愁
xiwangzishi
2022-01-11 10:01:32 +08:00
OpenResty: 这题我会
LIBQ
2022-01-11 10:47:42 +08:00
@cattyhouse 谢谢老哥 问题解决了
darknoll
2022-01-11 11:29:30 +08:00
同问下,caddy 里面怎么做

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/827422

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX