找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 15970|回复: 0

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

[复制链接]
发表于 2013-6-2 19:06:53 | 显示全部楼层 |阅读模式
反代了一个论坛,输入账号密码登录后,会跳转回原来的站。用了subs_filter也一样。6 x: ~3 \  R$ G: u* p6 f7 I/ M

6 G7 V$ H3 ~& ^' x一直在苦恼这个问题,经某人点拨,Discuz跳转的文件是xml后缀的(详情哪个文件我也不知道….)3 |; ^$ [1 `  _- E
  n+ @4 k; k. \9 s
打开ngx_http_substitutions_filter_module的github看到:
$ u6 [2 i0 T) ^4 r
3 M4 Y: _- u+ s
subs_filter_types
3 {: ~; B! Y! @/ f$ m- R6 M3 W" d syntax: *subs_filter_types mime-type [mime-types] *
. e$ s9 t; O1 W
4 j9 k3 J+ `' t' }default: *subs_filter_types text/html*
8 ~& A3 `& B) |, e% Q" w2 X* B6 O4 u6 y0 p
context: *http, server, location*
1 n4 a* ?0 {" p6 ^- u: o& U# F
2 L* S$ v1 \$ P*subs_filter_types* is used to specify which content types should be3 E4 R" c1 g) Z8 S: {
checked for *subs_filter*. The default is only *text/html*.
6 a! G  v* y! n( l, k6 o
. W& j8 [0 Y# }9 ~) Z7 }This module just works with plain text. If the response is compressed,
5 r  X. L7 R9 U. y7 C( L. L it can’t uncompress the response and will ignore this response. This
9 |/ b' U6 m$ |% F/ i module can be compatible with gzip filter module. But it will not work
3 O: w0 `- O9 w5 M' d! } with proxy compressed response. You can disable the compressed response
# T0 k5 O8 X, d7 ~5 m like this:
$ G  Q( I, W/ x2 _4 z, }! |
2 ]2 R2 _8 u- B8 b. Wproxy_set_header Accept-Encoding “”;

4 N/ F4 p( ~- t8 I
8 z1 o6 b: ^2 w; b7 X好吧,原来是没指定替换类型,默认只替换html
$ y; w& E4 N# z5 O/ Z+ c6 |2 S
  j5 P4 o+ b; o" ^4 |在nginx站点配置中加入下面代码:, ?  H4 U* o9 R# B
4 l2 z% z+ j5 Z% E
subs_filter_types text/css text/xml application/xhtml+xml application/xml;
4 r$ l( B2 R0 o; |3 ?  y
; y! ~1 |  A' w- {9 ?* d$ j/ u 重启nginx就解决了7 x6 s5 x8 e! c% T8 n
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-8-30 16:45 , Processed in 0.044814 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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