<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi, a strange thing, I found try_files won't work in the server context, only work in the location context. <div><br></div><div>I have a sample like this </div><div>try_files /maintenance.html $uri $uri/</div><div>location / {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>XXXX</div><div>}</div><div><br></div><div>then it won't work, but if I move the try_files into the location</div><div><br></div><div>location / {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>try_files /maintenance.html $uri $uri/</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>XXXX</div><div>}</div><div><br></div><div>then it works for root directory. </div><div><br></div><div>and it's a trouble that I have to put the try_files in each location, as I have .php, .jpg location. </div><div><div>location ~ \.php$ {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>fastcgi_pass 127.0.0.1:9000;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>fastcgi_index index.php;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>include fastcgi_params;</div><div>}</div></div><div><br></div><div>And I have to add the try_files in each of the location, is there any better solution. </div><div><br></div><div>I try to put the try_files out of the location, restarting nginx won't have any error, but it won't work when I access the site in the web browser. </div><div><br></div><div><br></div><div><div><div>On Apr 7, 2011, at 4:34 PM, Pascal Nitsche wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div bgcolor="#ffffff" text="#000000">
No not really.<br>
<br>
First you could send the status code by dynamic (ex. php) maintrance
file (I think this is a bad idea through...) Second you could do
something like this:<br>
<br>
<pre class="de1">try_files <i class="moz-txt-slash"><span class="moz-txt-tag">/</span>www/maintenance.html $uri $uri<span class="moz-txt-tag">/</span></i> <span class="re0">@maintrance;
</span>
<span class="kw3">location</span> <span class="re0">@maintrance</span><span class="br0"> {</span>
return 503<span class="sy0">;</span>
<span class="br0">}</span></pre>
<br>
<br>
Am 07.04.2011 10:19, schrieb Space Lee:
<blockquote cite="mid:A16AF996-70D9-46AE-9458-C87FAFAA5DA4@gmail.com" type="cite">So each time, if I want to change to a maintained
status, I have to add this line to the nginx configuration file
and then restart the config? Is there a simpler way, so that I
don't need to change the settings of the server.
<div><br>
<div>
<div>On Apr 7, 2011, at 4:15 PM, Pascal Nitsche wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div bgcolor="#ffffff" text="#000000"> Hello!<br>
<br>
To return a http status simply add "return STATUS_CODE;"
to your config location. So to return a 503 type:<br>
<br>
return 503;<br>
<br>
MfG<br>
<br>
Am 07.04.2011 10:13, schrieb Spacelee:
<blockquote cite="mid:BANLkTikro__52BC_W0rpOiZwoR+s8g3iLA@mail.gmail.com" type="cite">thanks, it works using try_files, and I put
it in the location / { }
<div>I try to setup 503 as you suggest, but I don't know
how to trigger the 503 status? </div>
<div><br>
</div>
<div><br>
<div class="gmail_quote">On Wed, Mar 23, 2011 at 11:39
PM, Vitaly Tskhovrebov <span dir="ltr"><<a moz-do-not-send="true" href="mailto:vt@chgk.info">vt@chgk.info</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt
0pt 0pt 0.8ex; border-left: 1px solid rgb(204,
204, 204); padding-left: 1ex;">On 3/23/2011 6:35
PM, Space Lee wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt
0pt 0pt 0.8ex; border-left: 1px solid rgb(204,
204, 204); padding-left: 1ex;"> I have a
question, if I want to use nginx to main the
maintenance file, and what's the easiest way for
me to change a web to maintained status when
it's in emergency?<br>
</blockquote>
<br>
try_files /www/maintenance.html $uri $uri/<br>
<br>
It will be better to return 503 in that case as
well.<br>
<br>
-- <br>
Regards, Vitaly Tskhovrebov<br>
System Administrator<br>
U.S. <a moz-do-not-send="true" href="tel:%2B1%20%28206%29%20905-9939" value="+12069059939" target="_blank">+1 (206)
905-9939</a><br>
Russia <a moz-do-not-send="true" href="tel:%2B7%20911%20094-2035" value="+79110942035" target="_blank">+7 911
094-2035</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a moz-do-not-send="true" href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a moz-do-not-send="true" href="http://nginx.org/mailman/listinfo/nginx" target="_blank">http://nginx.org/mailman/listinfo/nginx</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div><b>Space Lee</b></div>
<br>
</div>
<pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
nginx mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org">nginx@nginx.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://nginx.org/mailman/listinfo/nginx">http://nginx.org/mailman/listinfo/nginx</a>
</pre>
</blockquote>
<br>
</div>
_______________________________________________<br>
nginx mailing list<br>
<a moz-do-not-send="true" href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a class="moz-txt-link-freetext" href="http://nginx.org/mailman/listinfo/nginx">http://nginx.org/mailman/listinfo/nginx</a><br>
</blockquote>
</div>
<br>
</div>
<pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
nginx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org">nginx@nginx.org</a>
<a class="moz-txt-link-freetext" href="http://nginx.org/mailman/listinfo/nginx">http://nginx.org/mailman/listinfo/nginx</a>
</pre>
</blockquote>
<br>
</div>
_______________________________________________<br>nginx mailing list<br><a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>http://nginx.org/mailman/listinfo/nginx<br></blockquote></div><br></div></body></html>