simple try_files not working

Rapsey rapsey at gmail.com
Wed Feb 17 20:40:30 MSK 2010


What I want is for nginx to serve a file if it can (it exists), if not to
proxy the request to another server.
I'm using 0.8.33

server {
        listen 8080 default;
        server_name   ~^(www\.)?(?<domain>.+)$;
        index index.html index.htm;

        if ($host ~* www\.(.*)) {
          set $host_without_www $1;
          rewrite ^(.*)$ http://$host_without_www$1 permanent;
        }
        location / {
                root /var/www/htdocs/$domain;
                try_files $uri @def;
        }

        location ~ \.php$ {
                proxy_set_header Host $http_host;
                proxy_pass http://localhost:2000;
        }

        location @def {
               proxy_set_header Host $http_host;
               proxy_pass http://localhost:9090;
        }
    }
}

If I run:
curl -v -H "Host: domain.tv" "http://server_ip:8080/somefile"

The request always gets sent to the server on 9090, even though
/var/www/htdocs/domain/somefile exists.
What is wrong with my config?



thank you
Sergej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20100217/567b7453/attachment.html>


More information about the nginx mailing list