Welcome! Log In Create A New Profile

Advanced

Re: hi, is there a way to use nginx to publish the maintenance file

April 07, 2011 06:42AM
Hi, a strange thing, I found try_files won't work in the server context, only work in the location context.

I have a sample like this
try_files /maintenance.html $uri $uri/
location / {
XXXX
}

then it won't work, but if I move the try_files into the location

location / {
try_files /maintenance.html $uri $uri/
XXXX
}

then it works for root directory.

and it's a trouble that I have to put the try_files in each location, as I have .php, .jpg location.
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}

And I have to add the try_files in each of the location, is there any better solution.

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.


On Apr 7, 2011, at 4:34 PM, Pascal Nitsche wrote:

> No not really.
>
> 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:
>
> try_files /www/maintenance.html $uri $uri/ @maintrance;
>
> location @maintrance {
> return 503;
> }
>
>
> Am 07.04.2011 10:19, schrieb Space Lee:
>>
>> 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.
>>
>> On Apr 7, 2011, at 4:15 PM, Pascal Nitsche wrote:
>>
>>> Hello!
>>>
>>> To return a http status simply add "return STATUS_CODE;" to your config location. So to return a 503 type:
>>>
>>> return 503;
>>>
>>> MfG
>>>
>>> Am 07.04.2011 10:13, schrieb Spacelee:
>>>>
>>>> thanks, it works using try_files, and I put it in the location / { }
>>>> I try to setup 503 as you suggest, but I don't know how to trigger the 503 status?
>>>>
>>>>
>>>> On Wed, Mar 23, 2011 at 11:39 PM, Vitaly Tskhovrebov <vt@chgk.info> wrote:
>>>> On 3/23/2011 6:35 PM, Space Lee wrote:
>>>> 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?
>>>>
>>>> try_files /www/maintenance.html $uri $uri/
>>>>
>>>> It will be better to return 503 in that case as well.
>>>>
>>>> --
>>>> Regards, Vitaly Tskhovrebov
>>>> System Administrator
>>>> U.S. +1 (206) 905-9939
>>>> Russia +7 911 094-2035
>>>>
>>>> _______________________________________________
>>>> nginx mailing list
>>>> nginx@nginx.org
>>>> http://nginx.org/mailman/listinfo/nginx
>>>>
>>>>
>>>>
>>>> --
>>>> Space Lee
>>>>
>>>>
>>>> _______________________________________________
>>>> nginx mailing list
>>>> nginx@nginx.org
>>>> http://nginx.org/mailman/listinfo/nginx
>>>
>>> _______________________________________________
>>> nginx mailing list
>>> nginx@nginx.org
>>> http://nginx.org/mailman/listinfo/nginx
>>
>>
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://nginx.org/mailman/listinfo/nginx
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

hi, is there a way to use nginx to publish the maintenance file

fjctlzy March 23, 2011 11:36AM

Re: hi, is there a way to use nginx to publish the maintenance file

vt March 23, 2011 11:40AM

Re: hi, is there a way to use nginx to publish the maintenance file

fjctlzy April 07, 2011 04:14AM

Re: hi, is there a way to use nginx to publish the maintenance file

Pascal Nitsche April 07, 2011 04:18AM

Re: hi, is there a way to use nginx to publish the maintenance file

fjctlzy April 07, 2011 04:22AM

Re: hi, is there a way to use nginx to publish the maintenance file

Pascal Nitsche April 07, 2011 04:36AM

Re: hi, is there a way to use nginx to publish the maintenance file

fjctlzy April 07, 2011 06:42AM

Re: hi, is there a way to use nginx to publish the maintenance file

Maxim Dounin April 07, 2011 06:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 316
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