Ticket #190 (assigned defect)
nginx rewrite issue
| Reported by: | sbenthall | Owned by: | whit |
|---|---|---|---|
| Priority: | major | Milestone: | 1.1 Post-launch cleanup |
| Component: | Almanac (JS) | Keywords: | |
| Cc: | Total Hours: | 0.0 | |
| Estimated Hours: | 0 |
Description
The following rewrite rule in nginx.conf is broken:
location ~ ^/app.*/ {
rewrite ^/app(.+)/(.*)$ /++rest++app$1/++vh++http:${nginx-conf:broadcast-name}/app$1/++/$2 break;
proxy_pass http://${nginx-conf:upstream};
}
The intention is for the first group match only the version numbering of the application. I.e, if the url is
/app241/orton/...
then the first group would be "241". However, instead it matches "241/orton".
This becomes a problem when there is no trailing slash after the application name ('orton' in this example). And *that* becomes a problem when there is a query string appended to this url, i.e.,
/app241/orton?bbox=1231741354,174081702
This has been fixed with a workaround (writing the above URL with a slash before the question mark), but this requires some really gross javascript string manipulation just tacked on in various places in the templates. (I suppose it could be done in Zope as well, but it would still be gross).
The problem is that fixing this doesn't seem to be straightforward, because it looks like the virtual host *expects* the application name to be included in the first grouping. So if the regular expression is changed to, for example,
/app([/]*)/(.*)
, which would establish the desired behavior, things break and you get a 404.
