Git Product home page Git Product logo

iis-x-sendfile-plugin's Introduction

X-Sendfile and X-Accel-Redirect Support for IIS 7.x

This module provides basic support for X-Sendfile and X-Accel-Redirect headers.

As per Oct 7 2016, also X-Sendfile-Temporary is supported. When using this header, the file to be sent to the client is considered to be a temporary file and will be deleted from disc afterwards. In case you write software that can not know whether the installation supports this version of the module or the previous one without X-Sendfile-Temporary support, it can use both headers. The old version of the module will then pick up the X-sendfile header and the current version will pick up the X-Sendfile-Temporary method, so this provides a fallback mechanism.

Note that X-Sendfile-Temporary keeps the thread running until the result is fully streamed to the client. On intensive use, this can lead to thread shortages. When the CLR thread pool becomes exhausted, requests will start to queue, causing a hang.

Usage

Either compile again for the target .net environment or use the supplied .net 4 dll
For more details on what the below settings mean and do, please consult Apache or NGinx documentation

Install the DLL

  • Copy the assembly compiled to the /BIN directory located in the root of your application.
    • If this directory does not exist, create it.
  • Configure the module and handler to be loaded in the application.
    • Open the IIS7 Administration tool
    • double-click on your server node in the left-hand tree view, then expand the “Sites” node, and click on the site or application to which you would like to add your module and handler.
      • Select the “Modules” feature icon, then click the “Add Managed Module…” action, and in the resulting dialog box type in the module name (arbitrary) and the fully-qualified module type “XSendfile.XSendfileHttpModule”.
      • Press OK to add the module.

Select one of the optional configurations below:

Config the base directory if using X-Sendfile (optional)

  1. Open the IIS manager
  2. Select your web application
  3. Double click application settings
    • Click add…
    • name: XSendDir
    • value (for example): c:\inetpub\private

Config location if using X-Accel-Redirect (optional)

  1. Open the IIS manager
  2. Select your web application
  3. Double click application settings
    • Click add…
      • name: XAccelLocation
      • value (for example): /virtual/path
    • Click add…
      • name: XAccelRoot
      • value (for example): c:/base/dir

Common Settings

  • XSendCache: [NoCache|Private|Public] (defaults to NoCache)
  • XSendMime: False (defaults to null)
    • If this setting is not set then the mime type will be set using your IIS site mime settings
    • Setting this to false means the Content-Type header needs to be set by your application

Ensure IIS has access

  • Make sure the directory exists
  • You can run the following command to provide the IIS User read/write access
    • icacls c:\inetpub\private /grant BUILTIN\IIS_IUSRS:RW

iis-x-sendfile-plugin's People

Contributors

lexcon avatar stakach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iis-x-sendfile-plugin's Issues

IIS 10

this may be a dumb question but is there a way to get this to work on IIS 10?

.NET only? Global?

I haven't been able to get this plugin to work with ColdFusion yet. Must this be configured only as a "per-site" application (w/BIN in each root directory)? Is it possible to integrate it as a "global" module?

I use ColdFusion 10 & 2016 w/IIS 8.5 & 10 and both use Tomcat/Java. I'd like to use X-SendFile to eliminate locking up ColdFusion threads during long/slow file downloads. I know that some CF Devs use Unix/Apache, but some IIS installations have successfully used Boncode IIS Connector or Helicon Ape's X-SendFile to add X-SendFile capability.

I currently use IIS WebSpeed & IIS Brotli modules and am able to configure them globally for all websites. (IIS WebSpeed has customized ".config" files in each root directory. Brotli has no options other than global mime types.)

Regarding HTTP response headers, I currently add headers using ColdFusion so that IIS Webspeed's behavior can be modified after the content is returned from Tomcat and returned to IIS for delivery. I'd like to be able to do this with IIS-X-Sendfile-plugin, but I don't want to have to manually configure this in IIS Manager for every site. Can support be added for a root ".config" files or have it be configured as a global setting? (I'm not even sure if you are working on this anymore.)

Thanks.

Byte-range requests and Content-length

Hi there,

First off, thank you for creating this plugin, I appreciate your work very much on this.

I noticed an issue with the response headers returned by the plugin. If I make a request with: Range: bytes=0-1 on a file that is 50000 bytes, the response shows Content-Length: 50000 when it should show Content-Length: 2

In your code on line 101:
response.AddHeader("Content-Length", file.Length.ToString());

If a byte-range request is detected, it should use the length of the range instead of the length of the file.

I'd make this change myself but I don't develop in C# or .NET and don't have the appropriate tools. If you make the change I'll test it straight away.

Once again, thanks greatly for your work!

Not an issue

It would be nice if the module would support the header

X-SENDFILE-TEMPORARY

which would in effect remove the file after it was sent to the client.

License?

What is the license for this project?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.