Welcome! Log In Create A New Profile

Advanced

simple try_files not working

Rapsey
February 20, 2010 11:36AM
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
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

simple try_files not working

Rapsey February 20, 2010 11:36AM

Re: simple try_files not working

Igor Sysoev February 20, 2010 11:36AM

Re: simple try_files not working

Maxim Dounin February 20, 2010 11:36AM

Re: simple try_files not working

Tobia Conforto February 20, 2010 11:36AM

Re: simple try_files not working

Rapsey February 20, 2010 11:36AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 167
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready