Implementing Reverse Proxy

For a Windows Media server to act as a reverse proxy, the following must be true:

  • The client is not configured to use the server as a proxy. This means that the client treats the reverse proxy as if it is the origin server.

  • The server contains a cache proxy plug-in that instructs it to either stream content from a local cache or proxy content from the origin server.

For example, in the following diagram, the client requests RTSP:://RevProxy/Movie.wmv, and the reverse proxy calls a plug-in to redirect the client or proxy the content. To the client, the proxy appears to be the origin server.

Diagram illustrating reverse proxy.

Dd892414.wms8_rev_proxy_final(en-us,VS.85).gif

You can use a reverse proxy to balance loads and increase security. To increase the security of the origin server, all client requests are routed to the reverse proxy server. The proxy server retrieves content from the origin server and streams it to the client so that the client never directly communicates with the origin server. To balance the load on the origin server, you can cache and deliver content from multiple reverse proxies.

A Windows Media server acting as a reverse proxy can either redirect a client or it can proxy a stream. You can implement this functionality by writing a custom cache proxy plug-in or by writing an event notification plug-in.

Using a Cache Proxy Plug-in To Implement Reverse Proxy

To implement a reverse proxy by using a custom cache proxy plug-in, you must first specify True for the EnableReverseProxyMode property on the IWMSServer interface. The server then associates a reverse proxy flag with the client request and sends the request to the plug-in. That is, the server creates a bitwise OR between WMS_CACHE_QUERY_OPEN, WMS_CACHE_QUERY_GET_CONTENT_INFO, or WMS_CACHE_QUERY_CACHE_EVENT, and the WMS_CACHE_QUERY_REVERSE_PROXY value, and then calls QueryCache on the IWMSCacheProxy interface.The plug-in can then test for the WMS_CACHE_QUERY_REVERSE_PROXY value and determine what action to take if the server is in reverse proxy mode.

One of the characteristics that distinguishes a reverse proxy from a typical cache proxy server is that the client is treating the reverse proxy as an origin server and requesting content directly from it. However, the reverse proxy typically does not have the requested content and must determine what action to take based on the knowledge of the person administering the reverse proxy. That is, there must be some way for the plug-in to associate the client's request with the location of the content. For more information about creating a cache proxy plug-in, see Implementing Cache Proxy Functionality.

Using an Authorization Plug-in to Implement Reverse Proxy

To implement a reverse proxy by using a custom authorization plug-in, you must trap the WMS_EVENT_LOGICAL_URL_TRANSFORM event. This event is raised when the server takes the logical URL requested by a client and maps it to a publishing point. The WMS_PRESENT_ORIGINAL_REQUEST_NAME property in the presentation context contains the requested URL.

To redirect the client, the authorization plug-in traps the WMS_EVENT_LOGICAL_URL_TRANSFORM event, places an alternate URL into the WMS_PRESENT_REQUEST_NAME property of the presentation context, and returns NS_E_REDIRECT to the server when the server calls the AuthorizeEvent method on the IWMSEventAuthorizationPlugin interface. This forces the server to redirect the client to an alternate URL.

To proxy the requested content to the client, the plug-in traps the WMS_EVENT_LOGICAL_URL_TRANSFORM event, places the URL to proxy from in the WMS_PRESENT_REQUEST_NAME property of the presentation context, and returns S_OK (instead of NS_E_REDIRECT) when the server calls AuthorizeEvent. The server eventually passes the event to the cache manager, and the cache manager calls the cache proxy plug-in.

For more information about creating authorization plug-ins, see Creating Authorization Plug-ins.

See Also (General)

See Also (Visual Basic .NET)

See Also (C#)

See Also (C++)

  • IWMSCacheProxy::QueryCache

  • IWMSEventAuthorizationPlugin::AuthorizeEvent

  • IWMSServer::put_EnableReverseProxyMode