snap-core-0.9.3.1: Snap: A Haskell Web Framework (core interfaces and types)

Safe Haskell | None

Snap.Util.Proxy

Description

This module provides facilities for patching incoming `Requests` to correct the value of `rqRemoteAddr` if the snap server is running behind a proxy.

Example usage:

     m :: Snap ()
     m = undefined  -- code goes here

    applicationHandler :: Snap ()
     applicationHandler = behindProxy X_Forwarded_For m

Synopsis

- data ProxyType
  - = NoProxy
  - | X_Forwarded_For
- behindProxy :: MonadSnap m => ProxyType -> m a -> m a

# Documentation

data ProxyType

What kind of proxy is this? Affects which headers `behindProxy` pulls the original remote address from.

Currently only proxy servers that send `X-Forwarded-For` or `Forwarded-For` are supported.

Constructors

NoProxy | no proxy, leave the request alone
X_Forwarded_For | Use the `Forwarded-For` or `X-Forwarded-For` header

Instances

Eq ProxyType |
Ord ProxyType |
Read ProxyType |
Show ProxyType |

behindProxy :: MonadSnap m => ProxyType -> m a -> m a

Rewrite `rqRemoteAddr` if we're behind a proxy.