Apache - AddHandler vs SetHandler

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
7/28/2005 2:00:10 PM
Gravatar
Total Posts 4

Apache - AddHandler vs SetHandler

You may or may not consider this a bug, but it has caused problems for at least one of my clients.  The use of SetHandler versus AddHandler in the Apache installation instructions.

I don't see any (obvious) harm in changing this variable, in fact, I suspect many advantages to changing this .  Non-ASPX files will be sent directly from Apache, rather than passing into Mono.  Featurewise, it will allow non-ASP content to be served, this will facilitate integrating mojoPortal with legacy scripts and other non-ASP content.

The Apache installation instructions suggest using this broad statement:
SetHandler mono

While the following should be sufficient:
AddHandler mono aspx

I've made this change for one client and so far it hasn't caused any problems.  Of course, I'll let you know if I hear back otherwise :-)

--
Eric Windisch
7/28/2005 3:12:02 PM
Gravatar
Total Posts 18439

Re: Apache - AddHandler vs SetHandler

Hi Eric,

I do think you can use that approach in some cases if it solves some problems but there are some issues with it.

Even if you use that approach you will want to make mono the handler for more than just .aspx

For example you should make it handle .config because for security reasons you don't want the Web.config to be served up by some other handler as it has the connection string and other app settings. mono knows not to allow .config files to be served.

In fact the Shared files module of mojoPortal utilizes this feature for security. When a user uploads a file it is saved to disk with a guid string name and .config extension while the friendly name is stored in the db. This prevents the file from being requested using http and obfuscates the name so it can't be guessed easily. mono will serve it up to authorized users using Response.WriteFile(path);

For similar reasons you would also want .ascx .cs .resx (maybe more I'm sleepy) to be handled by mono and probably also .dll since you don't want the compiled stuff to get served. Admittedly .cs files shouldn't be deployed but I've seen people do it.

Also this would break a feature of the Friendly Url mapper in mojoportal, which allows mapping urls like http://www.mojoportal.com/Forums to a specific page because the request would not be handled by mono and would therefore bypass the mapping logic and result in a 404.

So I wouldn't want that to be a blanket rule.

If you use  SetHandler mono I wonder if its possible to make it still use a different handler for other content like .gif .png etc and force some other things not to be handled by mono while letting anything unspecified be handled by mono. That would be ideal.


Joe
7/31/2005 4:51:16 PM
Gravatar
Total Posts 4

Re: Apache - AddHandler vs SetHandler

From your description, it sounds like you really do need the broad SetHandler.

> If you use  SetHandler mono I wonder if its possible to make it still use a different handler for other
> content like .gif .png etc and force some other things not to be handled by mono while letting anything
> unspecified be handled by mono. That would be ideal.

If only we lived in a perfect world! :(   The only way I know of to  what you suggest above is to use mod_rewrite and mod_proxy against another VirtualHost which doesn't parse mono -- but then that other virtualhost will need to either use another document root or block any sensitive files. 
9/1/2005 2:06:01 PM
Gravatar
Total Posts 18439

Re: Apache - AddHandler vs SetHandler

Eric,

Dean Brettle recently showed me a way to configure apache to serve some files that are not mono specific

Inside the Virutal Host:
#This causes the xsl file (and other static files) to be served directly by Apache
#instead of Mono. This necessary because Mono sends a Content-Type of
#"application/octet-stream" for the xsl file and that confuses the browser.


SetHandler None


Joe
You must sign in to post in the forums. This thread is closed to new posts.