302 without version in html

96 views
Skip to first unread message

nocontrol

unread,
Dec 4, 2020, 3:47:11 AM12/4/20
to openresty-en
While redirecting with 302, openresty outputs its version within the html output.
How can we prevent this?

We would like to get a 302 response without any information about the product and its version.

How can we achieve this?

Best Regards
nocontrol


< HTTP/1.1 302 Found
< Date: Fri, 04 Dec 2020 08:25:29 GMT
< Server: Apache
< Vary: Referer,User-Agent
< Set-Cookie: Path=/; Secure; HttpOnly; SameSite=Lax
< Content-Length: 151
< Cache-Control: no-cache, no-store, max-age=0
< Location: https://www.....
< X-Frame-Options: SAMEORIGIN
< Strict-Transport-Security: max-age=16070400
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< Referrer-Policy: same-origin
< Content-Type: text/html
<
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center>openresty/1.15.8.3</center>
</body>
</html>

Marlon Moyer

unread,
Dec 4, 2020, 10:03:50 AM12/4/20
to openre...@googlegroups.com
you can use the `error_page` directive in your config file like this

`error_page 301 302 /30x.html;` 

then create the 30x.html with whatever you want inside of it.



--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openresty-en/e2d534a4-3047-4ec2-956d-bf09e214d7c3n%40googlegroups.com.

Kshitij Joshi

unread,
Apr 2, 2021, 8:14:02 PM4/2/21
to openresty-en
You can also use

body_filter_by_lua_file /usr/local/openresty/lualib/body_content.lua;

if ngx.status == 302 then
-- Nginx output filters may be called multiple times for a single request because the response body may be delivered in chunks.
-- Thus, the Lua code specified by in this directive may also run multiple times in the lifetime of a single HTTP request.
-- The input data chunk is passed via ngx.arg[1] (as a Lua string value).
-- The "eof" flag indicating the end of the response body data stream is passed via ngx.arg[2] (as a Lua boolean value).
-- Hence, we force Nginx to believe that is if EOF and then send an Empty Body
ngx.arg[2] = true
ngx.arg[1] = ""
return
end

Reply all
Reply to author
Forward
0 new messages