Rewriting and proxy problem
Francis Daly
francis at daoine.org
Sat May 25 09:27:16 UTC 2013
On Fri, May 24, 2013 at 02:39:58PM -0300, Sergio Belkin wrote:
Hi there,
> I am completeley newbie to nginx
Welcome.
The nginx config follows its own logic, which may not match your previous
experiences. When you understand that, you'll have a much better chance
of knowing the configuration you are looking for.
One important feature is that one request is handled in one
location. Another is that one http request does not necessarily correspond
to one nginx request.
In this case...
you make the request for /demoX, and the best-match location is "location
/demo", and so that is the one that is used.
> location /demo {
> rewrite ^ /upvc;
Once that happens, you are using the new internal-to-nginx request
"/upvc", so a new choice for best-match location happens, and the rest
of this location{} block is not relevant.
> proxy_pass http://127.0.0.1:8080;
> include fastcgi_params;
Aside: the fastcgi_params file will typically have content relevant for
when fastcgi_pass is used, not for when proxy_pass is used.
So, the http request for /demoX leads to the nginx request for /upvc,
which matches this location:
> location /upvc {
> alias /var/lib/tomcat6/webapps/demo;
> index demo3.jsp;
> expires 1m;
And here, you say "serve it from the filesystem", so that's what it does.
(I suspect that you actually get a http redirect to /upvc/, which then
returns the content of /var/lib/tomcat6/webapps/demo/demo3.jsp. Using
"curl" as the browser tends to make clear what is happening.)
> }
> Rewrite is working but nginx is not. proxying to tomcat, because of that
> returns the jsp file as a plain text file.
>
> Please could you help me?
The hardest part of nginx config that I find, it working out what exactly
you want to have happen for each request.
>From the above sample config, I'm not sure what it is that you want.
Perhaps putting the proxy_pass in the "location /upvc" block will work? Or
perhaps removing the rewrite?
If you can describe what behaviour you want, then possibly the nginx
config to achieve it will become clear.
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list