forced 404 without a location display ?
Oleg A. Mamontov
oleg at mamontov.net
Mon Jul 11 20:25:34 UTC 2016
On Mon, Jul 11, 2016 at 03:26:30PM -0400, Jonathan Vanasco wrote:
> I have some servers where I use an old method of gating a path by using a file check.
>
> this allows staff to turn off certain locations during migrations/updates without having root privileges (needed to restart nginx)
>
> an issue I noticed– this method now (perhaps always) shows the name of the location on the default 404 template [the response that nginx generates via code, not a template on the fs]
>
> Does anyone know how to disable showing the location without defining a custom template on the filesystem? or perhaps someone can think of a better way to accomplish my goals?
>
>
>
> location /paths/to/ {
> if (!-f /etc/nginx/_flags/is_running) {
> rewrite ^.*$ @is_running break;
> }
> }
> location = @is_running {
> return 404;
> }
>
> =======
> that generates this
>
>
> <html>
> <head>
> <title>404 Not Found</title>
> </head>
> <body>
> <h1>404 Not Found</h1>
> The resource could not be found.<br/><br/>
> /@is_running
>
>
> </body>
> </html>
=============================================
location /paths/to/ {
if ( !-f /etc/nginx/_flags/is_running ) {
rewrite ^ /is_running last;
}
}
location = /is_running {
internal;
return 404 'nothing\n';
}
=============================================
Does it work for you?
--
Cheers,
Oleg A. Mamontov
mailto: oleg at mamontov.net
skype: lonerr11
cell: +7 (903) 798-1352
More information about the nginx
mailing list