Welcome! Log In Create A New Profile

Advanced

Re: How to config nginx to download html file instead of opening it?

August 28, 2009 02:09AM
I found the solution:

#don't ever send $request_filename in your response, it will expose your dir struct, use a quick regex hack to find just the filename
if ($request_filename ~* ^.*?/([^/]*?)$)
{
set $filename $1;
}

if ($filename !~* ^.*?\.(html)|(htm)$)
{
add_header Content-Disposition "attachment; filename=$filename";
}
Subject Author Posted

How to config nginx to download html file instead of opening it?

jzhang August 25, 2009 04:51AM

Re: How to config nginx to download html file instead of opening it?

J August 25, 2009 05:29AM

Re: How to config nginx to download html file instead of opening it?

Igor Sysoev August 25, 2009 05:46AM

Re: How to config nginx to download html file instead of opening it?

jzhang August 25, 2009 10:25PM

Re: How to config nginx to download html file instead of opening it?

jzhang August 27, 2009 09:18PM

Re: How to config nginx to download html file instead of opening it?

Nick Pearson August 28, 2009 09:27AM

Re: How to config nginx to download html file instead of opening it?

jzhang August 28, 2009 02:09AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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