ITeye博客

nginx根据COOKIE信息重定向URL并将COOKIE转换为QUERYSTRING

jdkleo · 2017-10-17 18:13 · linux · nginx · 操作系统 · Markdown

location /{
	set $ody_cookie "";
	if ($http_cookie ~* "ody_ab_gray_group=(.*)"){
		set $ody_cookie "ody_ab_gray_group=$1";
	}
	if ($query_string ~* "^\?.*"){
		rewrite ^(.*)  ^$1&$ody_cookie break;
	}
	if ($query_string !~ "^\?.*"){
		rewrite ^(.*)  ^$1?$ody_cookie break;
	}
    proxy_pass http://localhost:8080;
    proxy_set_header Host $host:80;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For  $remote_addr;
    break;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。