Welcome! Log In Create A New Profile

Advanced

about error_page and named location

任晓磊
November 29, 2012 09:34PM
For rejecting some unfriendly access, I use 410 status code for them. The
config is below:

error_page 410 /410;
if (xxx) {
return 410;
}

location /410 {
more_set_headers "Content-Type: text/html;charset=utf8;";
return 410 '$remote_addr 禁止访问云云';
}

When I access it for testing purpose, I got
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>410 Gone</title></head>
<body bgcolor="white">
<h1>410 Gone</h1>
<p>The requested resource is no longer available on this server and there
is no forwarding address. Please remove all references to this
resource.<hr/>Powered by Tengine
</body>
</html>

If I use error_page 410 @410; and location @410{...} , it works correctly,
and serves a page with my own message.

So,
1st, What's the differences between norma location and named location, in
this context?
2nd, Are there better ways to serve a html page to unfriendly access, and
use nginx's variables in the html? I tried return 410 '$remote_addr
rejected' ,but it gave a application/octet-stream response, browser would
download it instead of display the message in browser window. So I have to
use more headers module to set Content-Type.
--
Ren Xiaolei
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

about error_page and named location

任晓磊 November 29, 2012 09:34PM

Re: about error_page and named location

Maxim Dounin November 30, 2012 02:52AM

Re: about error_page and named location

Ruslan Ermilov November 30, 2012 05:04AM

Re: about error_page and named location

任晓磊 November 30, 2012 11:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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