找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 16337|回复: 0

解决nginx反代Discuz论坛登录跳回源站的问题

[复制链接]
发表于 2013-6-2 19:06:53 | 显示全部楼层 |阅读模式
反代了一个论坛,输入账号密码登录后,会跳转回原来的站。用了subs_filter也一样。4 t% C! d" b; ^4 C, g/ @7 U

# }) o: G, x! |, }一直在苦恼这个问题,经某人点拨,Discuz跳转的文件是xml后缀的(详情哪个文件我也不知道….)
2 i9 Z. i" {/ A$ I9 `: m. N. T+ V
) ^2 `% m  m* U; {( k) _3 n打开ngx_http_substitutions_filter_module的github看到:
3 k; [* c/ b+ p% p  L; l' J0 d" `1 u  Q3 Y: w6 L9 r7 B
subs_filter_types5 d0 ?0 j1 C% i7 _) \& @1 j
syntax: *subs_filter_types mime-type [mime-types] *
3 V8 ]" O6 n+ [4 @3 o2 B: r
  ~) F$ R' K6 n( G2 [default: *subs_filter_types text/html*
# H- U* D6 b* \: ^: b2 c' @% K' W- F9 X$ ?$ R; d% }& ^+ I
context: *http, server, location*$ B. N1 w: \* u5 ?! t" ~

# g8 c- Z) I& L) @" V*subs_filter_types* is used to specify which content types should be
, ?4 \5 q  }. T/ i/ K$ N0 U checked for *subs_filter*. The default is only *text/html*.5 P6 {) l2 o3 D, S8 E. X& a

+ l6 r5 B, m, [4 g( K2 H- _9 U; kThis module just works with plain text. If the response is compressed,
$ I! `% G1 v/ X2 P% h0 ? it can’t uncompress the response and will ignore this response. This% ^8 @  D& B5 C9 m& X  G. e' ^
module can be compatible with gzip filter module. But it will not work
3 ?3 o. p1 Q, g8 c, x2 H9 c with proxy compressed response. You can disable the compressed response$ t7 m7 w/ e. V7 m7 f
like this:9 E" K. h$ `2 m, l( y  q9 `  z9 i
' \3 C% r* C/ Y2 E: `: T! m
proxy_set_header Accept-Encoding “”;
* ^& e  W) l  a
% E& R& D. m1 `8 x
好吧,原来是没指定替换类型,默认只替换html9 z+ |* J! S$ u! r$ e

  U! i) {) X5 G; [; ~在nginx站点配置中加入下面代码:
7 s: m( ~0 B1 y" c) H  k- k3 A2 d% u! d4 F( p" M0 }' Z; C
subs_filter_types text/css text/xml application/xhtml+xml application/xml;
2 m5 ?" i, n! e& H4 L. V5 h* y
& n0 w+ Z5 y- p 重启nginx就解决了, f1 l2 U8 H( I8 d$ X
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|第一站论坛 ( 蜀ICP备06004864号-6 )

GMT+8, 2026-10-5 02:51 , Processed in 0.063016 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表