Ticket #190 (assigned defect)

Opened 6 months ago

Last modified 2 months ago

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.

Change History

Changed 6 months ago by sbenthall

  • milestone changed from 1.0 Stable Release to 1.1 Improvements

Changed 5 months ago by whit

would include changing app -> REST

Changed 5 months ago by whit

  • owner set to whit
  • status changed from new to assigned

Changed 3 months ago by slinkp

  • estimatedhours set to 0

There are some related problems in the generated config file,
see http://lists.opengeo.org/orton-almanac/almanac-development-list/archive/2008/10/
1224350145976

Changed 2 months ago by slinkp

The issues with including the application name in the rewrite rules have been fixed in r1820.
If you set the correct appname in buildout.cfg, nginx.conf will be correct for those.

I didn't change the version number regex because of Seb's final comment ("things break and you get a 404"). I tried that change and didn't notice breakage, but I don't know which things would break.

Note: See TracTickets for help on using tickets.