> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Policy Condition for HTTP and WebSocket Services in API Proxy

If both HTTP and WebSocket services are running on the same proxy, a condition must be added to the relevant policies so that Apinizer policies can only be applied to HTTP requests. Thanks to this condition, WebSocket connections continue to work without being affected by policy checks.

In the example scenario, the script policy added to the API proxy adds a specific `Authorization` header to HTTP requests. However, it is intended that this script policy should not be applied in WebSocket requests.

Script policy is added:

<img src="https://mintcdn.com/apinizer/lhDPzGbbUaug0STI/images/tutorials/http1.png?fit=max&auto=format&n=lhDPzGbbUaug0STI&q=85&s=e98e7db2e18b961e50ee93f2ddd04280" alt="Generate JWK Screen" width="1000" data-path="images/tutorials/http1.png" />

On the Script policy screen, switch to the **Conditions** tab and add a new rule.

Select **header:Upgrade** as variable if it exists; otherwise, add the **Upgrade** header as a new variable of type **header**.

<img src="https://mintcdn.com/apinizer/lhDPzGbbUaug0STI/images/tutorials/http2.png?fit=max&auto=format&n=lhDPzGbbUaug0STI&q=85&s=a7aff6f61038ab72d682818df2426ebf" alt="Generate JWK Screen" width="1000" data-path="images/tutorials/http2.png" />

The condition for the **Upgrade header** is arranged and saved as follows to cover requests with the value **websocket**:

<img src="https://mintcdn.com/apinizer/AKKOKz2ciq_Ak4wy/images/tutorials/http3.png?fit=max&auto=format&n=AKKOKz2ciq_Ak4wy&q=85&s=271add638a65cd910c16d319760e8f85" alt="Generate JWK Screen" width="1000" data-path="images/tutorials/http3.png" />

Thus, requests with Upgrade header as websocket are filtered by condition, the script policy is only applied to HTTP requests, and the policy is disabled in WebSocket connections. This way, WebSocket traffic continues to work without being affected.
