找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 14757|回复: 0

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

[复制链接]
发表于 2013-6-2 19:06:53 | 显示全部楼层 |阅读模式
反代了一个论坛,输入账号密码登录后,会跳转回原来的站。用了subs_filter也一样。
  ^7 }' T- ?4 P( d/ E$ _' H
% s% m7 ?- h1 T' |1 S% }3 C- Z一直在苦恼这个问题,经某人点拨,Discuz跳转的文件是xml后缀的(详情哪个文件我也不知道….)
, d, f  D  o/ e9 G& G9 C
  @/ P  e' E2 Z2 l. f1 x+ x7 \" I打开ngx_http_substitutions_filter_module的github看到:
+ Q( K. w+ [7 [: u& Y% r; j* }) `% E- `% H9 p
subs_filter_types' u  Z0 t! n! R4 ?
syntax: *subs_filter_types mime-type [mime-types] *0 ^4 H0 z( d+ |. V+ }; w" `6 N
4 n" I2 c, E2 H1 O+ t$ x
default: *subs_filter_types text/html*
) h  G3 h4 o. U( z( T+ l% @8 n. P7 B8 D) o0 n
context: *http, server, location*6 O0 W) g* W  i5 F' V: L' l0 H

5 h0 q6 e  l9 C& O. }3 d6 t*subs_filter_types* is used to specify which content types should be
- P6 W) Q3 Q6 ~, A checked for *subs_filter*. The default is only *text/html*.( o1 b  |8 X) ^) {9 `% z3 P6 N

  U7 J3 ~( j9 }# \0 T$ R2 |6 W1 fThis module just works with plain text. If the response is compressed,) }, G& |, r( `% k+ a
it can’t uncompress the response and will ignore this response. This
5 \( j" ]# v) ?1 o) ^' f module can be compatible with gzip filter module. But it will not work
6 a( @" _$ J6 \ with proxy compressed response. You can disable the compressed response
$ c+ ]- r9 m! r7 x: t like this:% U, }( P$ o7 J# k3 W# m8 w

$ F& R' \) o# v8 n$ B' x: Hproxy_set_header Accept-Encoding “”;
- F" b  r$ A: n/ b( v8 g0 Y5 I
- @) T1 i' ?8 a. D% J
好吧,原来是没指定替换类型,默认只替换html
- M5 x' S" b. Q- @( l7 ?+ l9 W: T( L; G/ g; F- f, s
在nginx站点配置中加入下面代码:
) r- j. H7 Z9 ]# A: S* v0 M; T
- @- W$ l0 {9 ^9 S, V subs_filter_types text/css text/xml application/xhtml+xml application/xml;3 F/ n3 [4 j7 x! A7 }

9 `. k6 b* x) T2 K+ [8 V 重启nginx就解决了: J4 _1 z( _1 ]$ @! ^) ^
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-4-16 21:27 , Processed in 0.062149 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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