How to redirect to another port and/or host ?

Topics: User Forum
Oct 29, 2008 at 8:52 AM
Edited Oct 29, 2008 at 8:55 AM
Hello every body,
i have install on my windows 2003 std an application HSF.exe (listenning to port 8081).
My web server IIS is listenning to port 80.
I have a web site named "mycompany.com"located in path "D:\MesSites\mycompany.com" on witch i have installed the filter ionic IIRF.
I want when i call:
"http://hsf.mycompany.com" to be redirected to "http://hsf.mycompany:8081" (or to "http://mycompany:8081") to call hsf.exe.

Is it possible and how?

For this, i have write this rule:
RewriteLog  C:\Inetpub\IonicIsapiRewriter-1.2.15-bin\Log\iirfLog.out
RewriteLogLevel 5

RewriteCond %{HTTP_HOST} (?:hsf\.)?mycompany\.com [I]
RewriteRule ^/(.*) http\://hsf.mycompany.com\:8081/$1 [I,U]

i can't reach the application : the page doesn't be found.

i obtain this log:

Tue Oct 28 23:55:25 -   504 - LogFile re-opened.
Tue Oct 28 23:55:25 -   504 - AwaitIniChangeAndReinit:  TerminateWatch = FALSE
Tue Oct 28 23:55:25 -   504 - FileChangeWatcher(): Await returns (TerminateWatch= FALSE)
Tue Oct 28 23:55:25 -   504 - FileChangeWatcher: Await()...
Tue Oct 28 23:55:25 -   504 - AwaitIniChangeAndReinit()...
Tue Oct 28 23:55:45 -  2676 - DllMain THREAD_DETACH
Tue Oct 28 23:55:45 -  2692 - DllMain THREAD_DETACH
Tue Oct 28 23:55:57 -  1608 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue Oct 28 23:55:57 -  1608 - OnUrlMap: storing physical path (D:\MesSites\mycompany.com\), in ptr (0x000ad798)
Tue Oct 28 23:55:57 -  1608 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Tue Oct 28 23:55:57 -  1608 - DoRewrites
Tue Oct 28 23:55:57 -  1608 - GetServerVariable_AutoFree: getting 'url'
Tue Oct 28 23:55:57 -  1608 - GetServerVariable_AutoFree - no joy (GetLastError()=1413)
Tue Oct 28 23:55:57 -  1608 - GetServerVariable_AutoFree: 128 bytes
Tue Oct 28 23:55:57 -  1608 - GetServerVariable_AutoFree: result ''
Tue Oct 28 23:55:57 -  1608 - GetHeader_AutoFree: getting 'url'
Tue Oct 28 23:55:57 -  1608 - GetHeader_AutoFree: 2 bytes, result '/'
Tue Oct 28 23:55:57 -  1608 - GetServerVariable_AutoFree: getting 'QUERY_STRING'
Tue Oct 28 23:55:57 -  1608 - GetServerVariable_AutoFree: 1 bytes
Tue Oct 28 23:55:57 -  1608 - GetServerVariable_AutoFree: result ''
Tue Oct 28 23:55:57 -  1608 - GetHeader_AutoFree: getting 'method'
Tue Oct 28 23:55:57 -  1608 - GetHeader_AutoFree: 4 bytes, result 'GET'
Tue Oct 28 23:55:57 -  1608 - DoRewrites: New Url: '/'
Tue Oct 28 23:55:57 -  1608 - EvaluateRules: depth=0
Tue Oct 28 23:55:57 -  1608 - EvaluateRules: Rule 1 : 2 matches
Tue Oct 28 23:55:57 -  1608 - GetServerVariable: getting 'HTTP_HOST'
Tue Oct 28 23:55:57 -  1608 - GetServerVariable: 26 bytes
Tue Oct 28 23:55:57 -  1608 - GetServerVariable: result 'gdt.alg-diagnosticimmo.fr'
Tue Oct 28 23:55:57 -  1608 - ReplaceServerVariables: VariableName='HTTP_HOST' Value='hsf.mycompany.com'
Tue Oct 28 23:55:57 -  1608 - ReplaceServerVariables: InputString='%{HTTP_HOST}' out='hsf.mycompany.com'
Tue Oct 28 23:55:57 -  1608 - EvalCondition: ts1 'hsf.mycompany.com'
Tue Oct 28 23:55:57 -  1608 - GenerateReplacementString: src='/','(null)' ReplacePattern='hsf.mycompany.com' vec=[[  [  0, 1, 1, 1] [] ] counts=2,0
Tue Oct 28 23:55:57 -  1608 - ApplyCaseConversion: before 'hsf.mycompany.com'
Tue Oct 28 23:55:57 -  1608 - ApplyCaseConversion: after  'hsf.mycompany.com'
Tue Oct 28 23:55:57 -  1608 - GenerateReplacementString: result 'hsf.mycompany.com'
Tue Oct 28 23:55:57 -  1608 - EvalCondition: checking 'hsf.mycompany.com' against pattern '(?:hsf\.)?mycompany\.com'
Tue Oct 28 23:55:57 -  1608 - EvalCondition: match result: 1 (match)
Tue Oct 28 23:55:57 -  1608 - EvaluateCondition: Child is NULL
Tue Oct 28 23:55:57 -  1608 - EvalCondition: returning TRUE
Tue Oct 28 23:55:57 -  1608 - EvalConditionList: rule 1, TRUE, Rule will apply
Tue Oct 28 23:55:57 -  1608 - ReplaceServerVariables: InputString='http\://hsf.mycompany.com\:8081/$1' out='http\://hsf.mycompany.com\:8081/$1'
Tue Oct 28 23:55:57 -  1608 - GenerateReplacementString: src='/','hsf.mycompany.com' ReplacePattern='http\://hsf.mycompany.com\:8081/$1' vec=[[  [  0, 1, 1, 1] [  0, 25] ] counts=2,1
Tue Oct 28 23:55:57 -  1608 - GenerateReplacementString: replacing ($1) with ''
Tue Oct 28 23:55:57 -  1608 - ApplyCaseConversion: before 'http\://hsf.mycompany.com\:8081/'
Tue Oct 28 23:55:57 -  1608 - ApplyCaseConversion: after  'http\://hsf.mycompany.com\:8081/'
Tue Oct 28 23:55:57 -  1608 - GenerateReplacementString: result 'http\://hsf.mycompany.com\:8081/'
Tue Oct 28 23:55:57 -  1608 - EvaluateRules: Result (length 40): http\://hsf.mycompany.com\:8081/
Tue Oct 28 23:55:57 -  1608 - EvaluateRules: depth=1
Tue Oct 28 23:55:57 -  1608 - EvaluateRules: Rule 1 : -1 (No match)
Tue Oct 28 23:55:57 -  1608 - EvaluateRules: returning 0
Tue Oct 28 23:55:57 -  1608 - EvaluateRules: returning 1
Tue Oct 28 23:55:57 -  1608 - DoRewrites: Rewrite Url to: 'http\://hsf.mycompany.com\:8081/'
Tue Oct 28 23:55:57 -  1608 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue Oct 28 23:55:57 -  1608 - OnUrlMap: storing physical path (D:\MesSites\mycompany.comhttp\:\hsf.mycompany.com\:8081\), in ptr (0x000c73b0)
Tue Oct 28 23:55:57 -  1608 - HttpFilterProc: SF_NOTIFY_LOG

I don't see what's wrong.
Any help will be pleased.
Thank's.
Coordinator
Oct 30, 2008 at 10:23 PM
You appear to be using a RewriteRule with a fully-qualified URL as the replacement pattern.  This won't work.
If you want a redirect, then you need a RedirectRule (using the latest 1.2.15 release).

If you have the latest release, then you will see in your logfile warnings and/or errors associated to your rules. You haven't included the relevant section of the logfile that documents the parsing of the ini-file.  But if you look in your logfile, you should see these warnings or errors. 

Search for the word ERROR or WARNING (all upper case).


Nov 3, 2008 at 9:02 PM
Even with a RedirectRule, i can't reach my application listenning on 8081.
Please, how to redirect the request  to another port?

Regards.
Alain
Coordinator
Nov 4, 2008 at 6:34 PM
Edited Nov 4, 2008 at 6:36 PM
I would have to see your updated rules and log file to help you.

Did you verify that there were WARNING or ERROR statements in the log file with your original rules?
Did you verify that there are no WARNING or ERROR statements in the log file with the modified rules?

In all cases, the first thing to check is that your ini file is valid.
There is a tool in the IIRF download to help do this:
TestParse.exe

Try it.