Troubles with proxy

Jul 7, 2009 at 6:28 PM


I've been trying to do this for a few hours now, the sample site works within Visual Studio, but I can't get my live to work.

My goal is to have access to some internal cameras from the outside.

User types in
Firewall directs http traffic to server running iis7
IIS 7 running URL Rewriter directs that request to an internal IP (http://192.168.1...)
Is this possible when the user can not directly access the 192 network from outside the firewall??

If it is possible, what do I put in my ManagedFusion.Rewriter.txt rule file?

I thought this would work:

RewriteEngine on

RewriteRule ^/CameraName/(.*)    http://192.168.1.../ [P]

Jul 7, 2009 at 7:10 PM

RewriteEngine On

RewriteRule ^/CameraName/(.*)$$1 [NC,P]

I don't quite understand your syntax, but try this.

Jul 7, 2009 at 7:33 PM
Edited Jul 9, 2009 at 2:44 PM

Hmm that also didn't work - I get a 404 error.. so I'm probably missing something basic in the setup.

I have the DLL and PDB file in the /bin/ directory, and I have the ManagedFusion.Rewriter.txt in the root of the website with the web.config. This is a brand new site on IIS so there are no other files or folders except the default ones that Visual Studio 2008 puts in there.

here is my webconfig using IIS 7

EDIT: I took out my web.config - it was fine, and it was making this page very wide.

Jul 7, 2009 at 9:01 PM

Turn on the RewriteLog and RewriteLogLevel and see what URL is actually getting proxied too.


Jul 7, 2009 at 9:39 PM

RewriteEngine On

RewriteLog "url.log"

RewriteLogLevel 9

RewriteRule ^/camera1/(.*)$$1 [NC,P]


When I go to  I get the same 404 error File or Directory not found.    

nothing is written to url.log   the url.log file is at the root (same level as web.config)

Jul 7, 2009 at 11:25 PM



RewriteLog c:\{path to your website}\log.txt

RewriteLogLevel 9



Jul 8, 2009 at 1:09 PM
Edited Jul 8, 2009 at 1:12 PM

RewriteEngine On


RewriteLog "C:\sites\\log.txt"

RewriteLogLevel 9

RewriteRule ^/camera1/(.*)$$1 [NC,P]



Thanks for your responses, Still nothing in the .txt file! EDIT: I tried it without quotes as well in the path.

Jul 8, 2009 at 2:49 PM

Try this latest test release in this work item

Jul 8, 2009 at 3:00 PM

OK I tried the new files and still 404 error, with nothing in the log.txt

Jul 8, 2009 at 3:33 PM

Don't know why there isn't anything in the log file.  If the log file is created by the server, it should be populating it. 

Secondly if you are still receiving a 404 error, that means that, the backend server (your camera) is returning that because the path you have passed it cannot be used.

Try setting up fiddler on your server and use Rick's method of setting up the proxy in the web.config for fiddler so that all requests to your camera have to pass through

the fiddler logger.

Jul 8, 2009 at 4:57 PM

I looked around but can't find Rick's method, can you direct me to it? I'm new to the community so not don't know these things yet! Thanks!

Jul 8, 2009 at 5:05 PM

Sorry I meant to include the link.

Jul 8, 2009 at 6:17 PM

Okay this sheds some light!

I was typing in  and Fiddler showed my request going to   and I know this does not exist on the camera. So I changed my rules.txt to be:

RewriteEngine On<font size="2">

RewriteLog "C:\sites\\log.txt"

RewriteLogLevel 9

RewriteRule ^/camera1/(.*)$ [NC,P]

and typed in the same URL to my browser. Fiddler shows the result as 200. IE still shows the page as 404 - however the IE window title has change to what my camera normally displays (Live View - AXIS Dome Camera) 

This means it got somewhere further than before, but IE still shows the 404 error. I took the proxy out of the webconfig and rebooted the IIS, but still get 404 in IE (but with the camera's window title).

What does that mean now?



Jul 9, 2009 at 12:14 AM

Well it could be many things.  Many of these camera websites are built around frames, so you maybe seeing an internal frame, while the outside one displays the title.  You need to look at the HTML source to see what URL's might be referenced and probably arn't covered by your current rule.

Jul 9, 2009 at 2:49 PM

I opened the camera locally on my developercomputer, I didn't notice anything in the HTML but there is a lot of java script. I ran Fiddler during my local request and there are many pages that get loaded. I edited these pages into the rules .txt file that URL Rewriter uses, and one of the pages loaded lots of HTML on my remote request - but I never got the video feed.

How can I edit the rules .txt file to properly get these other pages? This seems pretty advanced now! What should I provide to help build the rules file?

Jul 9, 2009 at 3:47 PM

When proxying there is really no magic bullet.  You need to get a list of all the requests and then make sure there is a rule to cover all of them.  Video should stream perfectly, as demonstrated in the PDC Video one the Home tab of this project.  However you have to make sure you have a rule to cover the video streaming URL.

Jul 9, 2009 at 3:48 PM

There seemed to be an issue with proxy-ing from the subfolder.. After the first rewrite, it would drop the /camera1/ from the chain and go to the root. So I took the /camera1/ out of the situation to try and just get one camera to work. If this works then I get just setup each camera with a subdomain (, etc).

Here are my new rules, 

RewriteEngine On

RewriteRule ^/(.*)$$1 [NC,P]

 So when I go to:  Rewrite sends me to  - with the below rules text file, I get everything to load except the video stream. So I'm very close now, I'll keep trying more things and read more samples (which has helped).

Jul 9, 2009 at 4:20 PM

Would the video not be streaming because there is no mime type for the video in IIS? The camera is using mjpg  (motion jpg) but I don't see this in the mime type listing.

Jul 9, 2009 at 4:49 PM

It could be, because I don't know how the codec works.  But, my ultimate guess is that you need to setup both fiddler on your desktop and server.  Make sure that all requests from your desktop is going to the server.  If one isn't or one is erroring out on your server that that is the problem.

Best way to do this is to just record what is happening when you see it directly using fiddler, and find the URL that is being used to get the server video feed.  Then try to add a rule for that video feed URL above your other rule.

Jul 9, 2009 at 9:00 PM
Edited Jul 9, 2009 at 9:03 PM

I made an interesting observation about the video.. in Fiddler, I can see all of the pictures and pages being proxied as I expected, but when it comes to do the video feed, fiddler sits on that request.

If I click on that request, it has the download arrow icon shown, and when I look at Statistics, at the bottom it says Download Progress xxx,xxx,xxx bytes, Hit F5 to refrseh.

As I press F5, it just keeps downloading and downloading, 100s of MBs.. but the stream never gets sent back to the browser that requested it in the first place. Eventually the request times out.

There must be some issue streaming this Motion JPEG format that axis is using using a proxy? I dunno! The file extention is mjpg - I'll be looking into more info about it.


EDIT: I forgot to mention, this Fiddler info was on the server.

Jul 10, 2009 at 4:51 PM

Today I started over on a server running IIS 6, to see if IIS 7 had some issue with MJPG - but the same thing occurs on this second server trying to proxy that mjpg file.

I can control the camera with the zoom/pan controls that load on the page, the only thing not going through is the video!

Jul 11, 2009 at 1:08 AM

Please record a good session not using the proxy and then save it. Then contact me on Then you can send me the file. Because this sounds more complicated than a forum can handle.

Jul 14, 2009 at 1:34 PM

Nick did you mean record a video, or record some Fiddler2 logs? Thanks!

Jul 14, 2009 at 2:52 PM

Fiddler log.

Jul 15, 2009 at 2:49 PM


Did you get my email? We've had some trouble sending emails recently, just confirming that you got it. No rush on response since I know this is your free-time project! Thanks for taking the time to review it,

Jul 15, 2009 at 4:53 PM

No I didn't.  Send to nberardi at

Aug 2, 2009 at 8:36 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.