<div>What I want is for nginx to serve a file if it can (it exists), if not to proxy the request to another server.</div>I&#39;m using 0.8.33<div><br></div><div><div>server {</div><div>        listen 8080 default;</div><div>
        server_name   ~^(www\.)?(?&lt;domain&gt;.+)$;</div><div>        index index.html index.htm;</div><div><br></div><div>        if ($host ~* www\.(.*)) {</div><div>          set $host_without_www $1;</div><div>          rewrite ^(.*)$ http://$host_without_www$1 permanent; </div>
<div>        }</div><div>        location / {</div><div>                root /var/www/htdocs/$domain;</div><div>                try_files $uri @def;</div><div>        }</div><div>        </div><div>        location ~ \.php$ {</div>
<div>                proxy_set_header Host $http_host;</div><div>                proxy_pass <a href="http://localhost:2000">http://localhost:2000</a>;</div><div>        }</div><div><br></div><div>        location @def {</div>
<div>               proxy_set_header Host $http_host;</div><div>               proxy_pass <a href="http://localhost:9090">http://localhost:9090</a>;</div><div>        }</div><div>    }</div><div>}</div><div><br></div><div>
If I run:</div><div>curl -v -H &quot;Host: <a href="http://domain.tv">domain.tv</a>&quot; &quot;<a href="http://server_ip:8080/somefile">http://server_ip:8080/somefile</a>&quot;</div><div><br></div><div>The request always gets sent to the server on 9090, even though /var/www/htdocs/domain/somefile exists.</div>
<div>What is wrong with my config?</div><div><br></div><div><br></div><div><br></div><div>thank you</div><div>Sergej</div></div>