proxy pass ajax problem
r at roze.lv
Fri Nov 16 08:36:29 UTC 2012
> hi all
> I am using nginx as a reverse proxy for neo4j(you can assume it as a
> http server). The problem is web page return by neo4j has ajax request
> which is sent to neo4j server.
> e.g. the neo4j server is localhost:7474 . and nginx is bind to 8000
> http://domain:8000/webadmin/ will send to http://domain:7474/webadmin/
> but the returned page will send ajax request with
> I want to the ajax request is also sent to
> http://domain:8000/ajax-path. How to do this?
The problem most likely is that the neo4j server is using it's own
servername/port for the url creation in the html.
Depending on the situation there are few ways you could fix/work arround it:
1. Change the neo4j/application source to use relative paths eg instead of
http://domain:7474/ajax-path just /ajax-path
2. nginx can override location headers by using proxy_redirect (
3. If you are unable to change the generated output from the neo4j backend
you could try to use the Sub module ( http://wiki.nginx.org/HttpSubModule )
in the proxy_pass location with something like:
sub_filter http://domain:7474 http://domain:8000;
.. and let nginx alter the source on the fly (though this isnt the best
solution from performance aspect / also there are some caveats if the
response from backend is compressed etc).
More information about the nginx