This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: Preventing courtesy 301/302 in IIS7.5
Author
Message |
Taomyn
Groupie


Joined: 04 September 2003
Location: Luxembourg
Posts: 65
Posted: 20 October 2010 at 7:16am

Hi,

This is an old problem that I have not been able to solve yet that I would like to get help on, this time from afresh.

I need to get Ape to prevent IIS 7.5 from 301/302'ing a particular request. What I need is for Ape to change:

https://www.mydomain.com/Microsoft-Server-ActiveSync

into

https://www.mydomain.com/Microsoft-Server-ActiveSync/

before IIS can deal with it and still pass all the various headers/parameters in the original request.

My reason for this? Well, when IIS receives a request without a trailing slash, it does a few things to "help" the browser. The rules for this are as follows:

Internet Information Server (IIS) first treats SubDir as a file that it should give back to the browser. If this file cannot be found, IIS checks to see if there is a directory with this name. If a directory with this name exists, a courtesy redirect with a 302 "Object moved" response message is returned to the browser. This message also contains the information about the new location of the directory with the trailing slash. In turn, the browser starts a new GET request to the URL with the trailing slash.

With this slash at the end of the URL, IIS treats this as a directory and tries to obtain either the default document from this directory or, if no default document exists, returns the directory listing or a "Directory listing denied" error message.

The full text of this can be seen here: http://support.microsoft.com/kb/298408 - although this only says up to II6, II7 and IIS7.5 both continue to do the same

Can this be acheived with Ape?
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 21 October 2010 at 3:22am

Hello.
Please make sure mod_dir is enabled in httpd.conf and try the following code in .htaccess:
Code:
DirectorySlash On

Thanks.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
Taomyn
Groupie


Joined: 04 September 2003
Location: Luxembourg
Posts: 65
Posted: 21 October 2010 at 3:43am

Checked httpd.conf and the line:

LoadModule dir_module          modules/mod_dir.so

is there

Added the code to .htaccess for the IIS site in question and I still get the same thing - checked using WFetch:

started....WWWConnect::Connect("www.mydomain.com","443")\nsource port: 58601\r\n
REQUEST: **************\nGET /Microsoft-Server-ActiveSync HTTP/1.1\r\n
Host: www.mydomain.com\r\n
Accept: */*\r\n
\r\n
RESPONSE: **************\nHTTP/1.1 301 Moved Permanently\r\n
Content-Type: text/html; charset=UTF-8\r\n
Location: https://www.mydomain.com/Microsoft-Server-ActiveSync/\r\n
Server: Microsoft-IIS/7.5\r\n
X-Powered-By: ASP.NET\r\n
Date: Thu, 21 Oct 2010 08:33:53 GMT\r\n
Content-Length: 178\r\n
\r\n
<head><title>Document Moved</title></head>\n<body><h1>Object Moved</h1>This document may be found <a HREF="https://www.mydomain.com/Microsoft-Server-ActiveSync/">here</a></body>WWWConnect::Close("www.mydomain.com","443")\nclosed source port: 58601\r\n
finished.

I tried the command in httpd.conf and still the same. Also, with the command in .htaccess I was getting these messages:

[21/10/2010 10:40:20] [dir_module] (4) [/sabnzbd/api?mode=qstatus&output=json&apikey=0xxxxxxxxd] Couldn't get attributes for D:\Websites\mydomain.com\sabnzbd\api: Unable to find the specified file.

Please advise.
Back to Top
 
Taomyn
Groupie


Joined: 04 September 2003
Location: Luxembourg
Posts: 65
Posted: 21 October 2010 at 4:14am

I have also noticed that any Rewrite rule I place in httpd.conf will only get triggered for my primary site, yet I have a server-wide licence.

I'm trying to see if I can kludge the problem by creating a second site which when I visit with /Microsoft-Server-ActiveSync which does not exist, gets changed to /Microsoft-Server-ActiveSyncX/ using Rewrite which does exist. When I visit this new secondary site my Rewrite rule does not get triggered yet it does for others in my primary site (rule not matched gets logged so I can see it).

I have to use a second site as IIS refuses to do this if the new URI does not use the same ApplicationPool as the original URI, which unfortunately for me they do not as the ActiveSync software needs to run as a different user and I cannot have the whole site running in this pool.
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 21 October 2010 at 4:14am

Please clarify the issue. As per WFetch response you got redirection from /Microsoft-Server-ActiveSync to /Microsoft-Server-ActiveSync/. Is that what you need?

As regarding the error message, I believe it belongs to different request. Could you please confirm if there is D:\Websites\mydomain.com\sabnzbd\api folder on your server.

Thanks.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
Taomyn
Groupie


Joined: 04 September 2003
Location: Luxembourg
Posts: 65
Posted: 21 October 2010 at 4:24am

Vyacheslav wrote:
Please clarify the issue. As per WFetch response you got redirection from /Microsoft-Server-ActiveSync to /Microsoft-Server-ActiveSync/. Is that what you need?


No, I do not want a 301/302 as ActiveSync mobiles do not follow them - I want IIS to take the request straight there

Vyacheslav wrote:
As regarding the error message, I believe it belongs to different request. Could you please confirm if there is D:\Websites\mydomain.com\sabnzbd\api folder on your server.

Thanks.


No, this folder does not exist - SABNZBD was a dummy folder used hold any .htaccess, but after your help I redirect using PROXYPASS. Maybe I don't need them any more.
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 21 October 2010 at 4:34am

Sorry for misleading. I though you needed redirection.

Please try the following code (the previous one should be removed):
Code:
RewriteEngine on
RewriteBase /
RewriteRule ^Microsoft-Server-ActiveSync$ /Microsoft-Server-ActiveSync/ [NC,L]


__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
Taomyn
Groupie


Joined: 04 September 2003
Location: Luxembourg
Posts: 65
Posted: 21 October 2010 at 5:02am

Still doesn't work

Just a thought, but watching the IIS logs when I try to connect my mobile phone the request it sends is an OPTIONS verb:

2010-10-21 09:44:33 192.168.1.10 OPTIONS /Microsoft-Server-ActiveSync Cmd=OPTIONS&User=taomyn%40mydomain.com&DeviceId=validate&DeviceType=Android 443 - 195.234.136.64 Android/0.3 200 0 0 71

I'm not sure how to emulate the uri-stem (Cmd=OPTIONS&User=taomyn%40mydomain.com&DeviceId=validate&DeviceType=Android) in WFetch, but without it I'm getting:

started....WWWConnect::Connect("www.mydomain.com","443")\nsource port: 59331\r\n
REQUEST: **************\nOPTIONS /Microsoft-Server-ActiveSync HTTP/1.1\r\n
Host: www.mydomain.com\r\n
Accept: */*\r\n
\r\n
RESPONSE: **************\nHTTP/1.1 200 OK\r\n
Allow: OPTIONS, TRACE, GET, HEAD, POST, COPY, PROPFIND\r\n
Server: Microsoft-IIS/7.5\r\n
Public: OPTIONS, TRACE, GET, HEAD, POST, PROPFIND, PROPPATCH, MKCOL, PUT, DELETE, COPY, MOVE\r\n
DAV: 1\r\n
MS-Author-Via: DAV\r\n
X-Powered-By: ASP.NET\r\n
Date: Thu, 21 Oct 2010 09:30:09 GMT\r\n
Content-Length: 0\r\n
\r\n
WWWConnect::Close("www.mydomain.com","443")\nclosed source port: 59331\r\n
finished.
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 21 October 2010 at 5:54am

Could you please provide me with error.log and rewrite.log files.
Thanks.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
Taomyn
Groupie


Joined: 04 September 2003
Location: Luxembourg
Posts: 65
Posted: 21 October 2010 at 6:27am

Vyacheslav wrote:
Could you please provide me with error.log and rewrite.log files.
Thanks.


Nothing appears in them
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 21 October 2010 at 6:47am

Please put the following code to httpd.conf
Code:
RewriteLogLevel 9
LogLevel debug


Make a few requests and you’ll see records in log files.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
Taomyn
Groupie


Joined: 04 September 2003
Location: Luxembourg
Posts: 65
Posted: 21 October 2010 at 6:59am

Sorry, when I said "Nothing", I meant that even after enabling those codes nothing regarding the rules was appearing except for ones for another request i.e. the one for SABNZBD which is happening from an external connection. When I use WFetch or my mobile to test the Microsoft-Server-Active sync URI, nothing is logged.

I think IIS is dealing with this request at a higher level than Ape so Ape never sees it.
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 22 October 2010 at 10:46am

Hi,
I think we’ve talked over Skype and had a live-meeting. Please ping me when you’re ready and we’ll try to solve the issue in real-time.
Thanks.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 
Taomyn
Groupie


Joined: 04 September 2003
Location: Luxembourg
Posts: 65
Posted: 26 October 2010 at 7:10am

Hi there,

Seems I've now found a workaround for the problem. By adding the DLL I need /Microsoft-Server-ActiveSync to execute as a handler for "*" it seems to override this behaviour and now IIS correctly handles it.

However, the general issue still exists that IIS intercepts URIs without a trailing slash before Ape can handle it.

Still at least it's working now
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 27 October 2010 at 6:53pm

Hello.
I’m glad you’ve got it working.
Please check “Request Filtering” section if there are some custom rules. It’s also possible that Microsoft URL Rewriter causes that behaviour.

__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version