Regex – how to excluded directory from nginx conf

nginxregex

in nginx conf file,i use:

location ~ \.jsp {
    proxy_pass   http://127.0.0.1:86;
}

to parse my jsp file, now,i want excluded directory /upload/

this directory is user upload file directory ,don't need parse JSP file.(http://example.com/upload/)

how to change my location ~ \.jsp { ?

i need parse JSP *.jsp but excluded /upload/ and it's subdirectory.

thanks all 🙂

Best Solution

Here is a list of Nginx Core Directives:
http://wiki.nginx.org/NginxHttpCoreModule

By skimming through these I can see there's probably more than one way to achieve this. I can't test it, but here's something that may work:

error_page 403 /forbidden.html;
location ^~ /upload/ {
    deny all;
}

However, I would advise against this; your upload directory should never sit inside your web root. You should simply move the folder to achieve what you're asking.