# http referer iRule assistence

**URL:** <https://community.f5.com/t/http-referer-irule-assistence/50778>\
**Category:** Technical Forums\
**Tags:** irules, application-delivery\
**Created:** [August 23, 2016, 4:00pm UTC](https://community.f5.com/t/http-referer-irule-assistence/50778 "2016-08-23T16:00:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sonny](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Sonny](https://community.f5.com/u/Sonny)\
**Post date:** [August 23, 2016, 4:00pm UTC](https://community.f5.com/t/http-referer-irule-assistence/50778/1 "2016-08-23T16:00:28Z")

</div>

I have the below iRule. I want to modify it so that if users insert images into the docs via the browser, the connection doesn’t break. It breaks because the images are coming from their local systems and not from sharepoint. I haven’t been able to think of anything dynamic. I.E., if the user inserts different types of images(jpeg, giff, etc…), videos, etc.

when RULE\_INIT { user-defined: enable/disable debug (1/0) set static::ref\_debug 0 } when HTTP\_REQUEST { This iRule will check the HTTP referer to make sure the

traffic arriving at the OWA is in-fact coming from Sharepoint. if { not ( [HTTP::uri] contains “/favicon” ) } { if { $static::ref\_debug } { log local0. "Incoming

referer: [HTTP::header Referer]" } switch -glob [string tolower [HTTP::header Referer]] { “[https://sharepoint/\](https://sharepoint/%5C)\*” { if { $static::ref\_debug } { log local0. "From

allowed referer - allow" } return } “[https://OWA/\](https://OWA/%5C)\*” { if { $static::ref\_debug } { log local0. "local

domain - allow" } return } default { if { $static::ref\_debug } { log local0. "from

disallowed referer - redirect" } HTTP::redirect [HTTP::header Referer] } } } }

---

<div class="post-metadata">

**Author:** ![Kai\_Wilke](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kai_wilke/32/24646_2.png) [@Kai\_Wilke](https://community.f5.com/u/Kai_Wilke)\
**Post date:** [August 23, 2016, 4:48pm UTC](https://community.f5.com/t/http-referer-irule-assistence/50778/2 "2016-08-23T16:48:51Z")

</div>

Hi Sonny,

you could simply add an additional whitelist for problematic web pages (e.g. upload page)…

```tcl
when HTTP_REQUEST { 

     This iRule will check the HTTP referer to make sure the traffic arriving at the OWA is in-fact coming from Sharepoint. 

    if { not ( [HTTP::uri] contains "/favicon" ) } { 
        if { $static::ref_debug } { log local0. "Incoming referer: [HTTP::header Referer]" } 
        switch -glob [string tolower [HTTP::header Referer]] { 
            "https://sharepoint/*" { 
                if { $static::ref_debug } { log local0. "From allowed referer - allow" } 
                return 
            } 
            "https://OWA/*" { 
                if { $static::ref_debug } { log local0. "local domain - allow" } 
                return 
            } 
            default {
                if { $static::ref_debug } { log local0. "from disallowed referer - redirect" }
                switch -glob -- [string tolower [HTTP::uri]] {
                    "*upload.aspx*" - \
                    "*attachment.aspx*" - \
                    "*somepage.aspx*" - \
                    "*whitelist.aspx*" {
                        if { $static::ref_debug } { log local0. "Explicitly whitelisted URL - allow" }
                        return
                    } 
                    default {
                        HTTP::redirect [HTTP::header Referer] 
                    }
                }
            } 
        } 
    } 
}

```

Cheers, Kai

---

<div class="post-metadata">

**Author:** ![Sonny](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Sonny](https://community.f5.com/u/Sonny)\
**Post date:** [August 23, 2016, 5:34pm UTC](https://community.f5.com/t/http-referer-irule-assistence/50778/3 "2016-08-23T17:34:23Z")

</div>

Thanks for the suggestion Kai. However, it didn’t work. The .aspx pages are accounted for with the “[https://sharepoint/](https://sharepoint/)_" and "[https://OWA/](https://OWA/)_”, right?

---

<div class="post-metadata">

**Author:** ![Sonny](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@Sonny](https://community.f5.com/u/Sonny)\
**Post date:** [August 24, 2016, 12:51pm UTC](https://community.f5.com/t/http-referer-irule-assistence/50778/4 "2016-08-24T12:51:10Z")

</div>

If you use \_.\_, it works!

switch -glob -- [string tolower [HTTP::uri]] { “\_.\_” { if { $static::ref\_debug } { log local0. “Explicitly whitelisted URL - allow” } return }

Hmm, the “star.star” doesn’t show up on DevCentral.
