Reputation: 191
I try to use a single domain to proxy several programs like this:
http://sa.com/rabbitmq/ ---> http://localhost:15672/
http://sa.com/zabbix/ ---> http://localhost:10000/
and my conf is blow:
location /rabbitmq {
rewrite /rabbitmq(.*) $1 break;
proxy_pass http://localhost:15672;
It works well until I click a queue name to watch the detail,
which url is as the title said:
http://sa.com/rabbitmq/api/#/queues/%2F/somequeue
an 404 error occured, I saw an request in dev-tools of chrome:
http://rabbitmq.testing.gotokeep.com:15672/api/queues/%2F/dailyNewLike?lengths_age=60&lengths_incr=5&msg_rates_age=60&msg_rates_incr=5
this request returned 404.
I guess that when rewrite
processed, the uri was decoded (.../%2F/... -> ...///...) and the extra slashes will be removed...
Is my guess right? Is there a solution?
Upvotes: 2
Views: 776
Reputation: 31
You can use $request_uri to prevent nginx decode the uri. use conf like below
location /rabbitmq {
if ($request_uri ~* "/rabbitmq/(.*)") {
proxy_pass http://localhost:15672/$1;
}
}
Upvotes: 0
Reputation: 5252
Your guess is good, but no, the real problem is that nginx converts %2F
into %252F
(%
-> %25
).
%2F
is vhost
name (/
). I don't found the real solution for this problem, and my workaround was to use other vhost
name which do not contains /
symbol (e.g. pool1
).
Upvotes: 1