反代了一个论坛,输入账号密码登录后,会跳转回原来的站。用了subs_filter也一样。
. d: H0 y6 F* j, P* u* d; l3 x+ J0 E0 m4 f: p. J5 r* Q# c
一直在苦恼这个问题,经某人点拨,Discuz跳转的文件是xml后缀的(详情哪个文件我也不知道….)6 m% R: ] q' R2 E& {8 `
( O5 j+ A' T4 O$ R9 _
打开ngx_http_substitutions_filter_module的github看到:
* o% E$ y, X' k7 I9 R+ i5 w h! V5 J8 }! G( ?. k0 K: x( A4 d
subs_filter_types* S. h3 ]7 |8 C+ q! q# F% [) f8 z: X
syntax: *subs_filter_types mime-type [mime-types] *
0 g3 @" ~3 }, \3 s, j
; ^% m% U+ x3 o% s* ]0 \7 l7 P9 O2 Wdefault: *subs_filter_types text/html*
& b% @& j* D' w' K
- Y: @( H3 J4 p8 D- g- q" L+ scontext: *http, server, location*( F8 G7 `" z5 q
7 Y6 b: l( z& D( T" Q*subs_filter_types* is used to specify which content types should be
2 K3 d- T' G1 v+ p7 G checked for *subs_filter*. The default is only *text/html*.6 d! U' U `1 g2 y& e, o: {" x
5 [+ t$ R! B N6 J- j$ P6 U }
This module just works with plain text. If the response is compressed,
/ K8 v5 M1 b5 ?' T it can’t uncompress the response and will ignore this response. This" |/ R& M& X4 o0 Z
module can be compatible with gzip filter module. But it will not work
9 B) @) L9 s2 x+ }: r/ j with proxy compressed response. You can disable the compressed response$ M3 E) U7 [! R1 Z+ `6 m; G
like this:
( B+ f0 W; O& Z9 t/ w0 g
' I$ X) F' H$ b8 V- F0 X% Qproxy_set_header Accept-Encoding “”;
" }8 l8 b4 `6 J9 |' u
3 l. t) k( A& G2 v: h) s, T4 d- a好吧,原来是没指定替换类型,默认只替换html
3 i6 I; g* [. e+ a- \3 ]4 d" w4 o+ P7 g7 a& s6 N! E7 v
在nginx站点配置中加入下面代码:
7 Q; _* S2 e. g; ?1 i. z5 \7 W' x0 j) S. X; I' @, ?+ }* B/ R& `! D
subs_filter_types text/css text/xml application/xhtml+xml application/xml;
V- D4 I5 {3 p/ x9 |+ I. y3 Z, q( ?9 x
重启nginx就解决了" B0 X4 d- p+ X: X( g% f
|