<div class="gmail_quote">On Wed, Feb 17, 2010 at 6:58 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello!<br>
<div class="im"><br>
On Wed, Feb 17, 2010 at 06:40:30PM +0100, Rapsey wrote:<br>
<br>
> What I want is for nginx to serve a file if it can (it exists), if not to<br>
> proxy the request to another server.<br>
> I'm using 0.8.33<br>
><br>
> server {<br>
> listen 8080 default;<br>
> server_name ~^(www\.)?(?<domain>.+)$;<br>
> index index.html index.htm;<br>
><br>
> if ($host ~* www\.(.*)) {<br>
> set $host_without_www $1;<br>
> rewrite ^(.*)$ http://$host_without_www$1 permanent;<br>
> }<br>
> location / {<br>
> root /var/www/htdocs/$domain;<br>
> try_files $uri @def;<br>
> }<br>
><br>
> location ~ \.php$ {<br>
> proxy_set_header Host $http_host;<br>
> proxy_pass <a href="http://localhost:2000" target="_blank">http://localhost:2000</a>;<br>
> }<br>
><br>
> location @def {<br>
> proxy_set_header Host $http_host;<br>
> proxy_pass <a href="http://localhost:9090" target="_blank">http://localhost:9090</a>;<br>
> }<br>
> }<br>
> }<br>
<br>
</div>This is not going to work at all since you have an extra "}".<br>
<div class="im"><br>
> If I run:<br>
> curl -v -H "Host: <a href="http://domain.tv" target="_blank">domain.tv</a>" "<a href="http://server_ip:8080/somefile" target="_blank">http://server_ip:8080/somefile</a>"<br>
><br>
> The request always gets sent to the server on 9090, even though<br>
> /var/www/htdocs/domain/somefile exists.<br>
> What is wrong with my config?<br>
<br>
</div>According to your config file should be at<br>
/var/www/htdocs/<a href="http://domain.tv/somefile" target="_blank">domain.tv/somefile</a> (note ".tv").<br>
<br>
Maxim Dounin<br><br></blockquote><div>Ahh I hate regular expressions. Thank you.</div><div>Anyone know how it would have to be formed to only take the middle part of the domain?</div><div><br></div><div><br></div><div>Sergej</div>
<div> </div></div>