alibaba / tengine

A distribution of Nginx with some advanced features
https://tengine.taobao.org
BSD 2-Clause "Simplified" License
12.84k stars 2.52k forks source link

Tengine使用Dyups模块不兼容rewrite #1471

Open forleeds opened 4 years ago

forleeds commented 4 years ago

Tengine版本:

Tengine version: Tengine/2.3.2
nginx version: nginx/1.17.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled

configure arguments: 
--prefix=/alidata/server/tengine \
--with-http_realip_module \
--with-luajit-lib=/usr/local/lib/ \
--with-luajit-inc=/usr/local/include/luajit-2.0/ \
--with-lua-inc=/usr/local/include/luajit-2.0/ \
--with-lua-lib=/usr/local/lib/ \
--with-ld-opt=-Wl,-rpath,/usr/local/lib \
--with-http_lua_module \
--add-module=./modules/ngx_http_upstream_dyups_module \
--add-module=./modules/ngx_http_upstream_check_module \
--add-module=/root/nginx-module-vts

Tengine配置:

server {
    listen 80;
    listen 443 ssl;

    server_name abc.icesr.com;
    ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_prefer_server_ciphers on;

    location /abc {
    **rewrite /abc/(.*)$ /$1 break;**
        proxy_redirect off;
        proxy_connect_timeout 3;
        proxy_read_timeout 60;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    set $core_nginx core_nginx;
        proxy_pass http://$core_nginx;
    }
}

upstream:

# curl localhost:81/upstream/core_nginx
server 172.30.28.141:80
server 172.30.45.192:80

500报错日志:

172.16.30.176|abc.icesr.com|[19/Jun/2020:19:10:24 +0800]|1592565024.906|"GET /abc/ HTTP/1.1"|500|596|"-"|"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"|"-"|"-"|0.048|-

如果将 rewrite去掉dyups模块能正常使用,请问是配置的问题?还是bug呢?

尝试了多个Tengine版本,问题依旧!

harry-xm commented 2 years ago

这是个配置问题,和 dyups 模块没有关系。带有 break 的 rewrite 会导致 Nginx 停止处理该 location 内 rewrite 语句以下所有 ngx_http_rewrite_module 模块中的指令,包括 set,所以后面的 set 指令会失效。可以把 set 移动到 rewrite 指令前面或去掉 break 来解决。原生 Nginx 也有这个问题,参考文档:https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite