cancel
Showing results for 
Search instead for 
Did you mean: 

LTM iRule to access F5 file

MABSJ
Nimbostratus
Nimbostratus

Hello team,

 

With an iRule is it possible to redirect a URL to a local file within F5 itself?

For example, when accessing to the url http://example.com/local/etc/file1

 where example.com is a VS of the F5 

should load a file that has the F5 in one of its directories:

/example.com/local/etc/file1

 

We would like to do this to automate the loading of certificates in f5 by means of a script that is programmed in f5 itself. We only need to know if it is possible to obtain an f5 file trying to access a url whose domain is a vs f5.

 

Best regards.

3 REPLIES 3

cjunior
Nacreous
Nacreous

Hi,

Why don't you do it by creating ifiles and run in a statement?

 

e.g.

GET http://exmple.com/Common/file1

when HTTP_REQUEST { if { [catch { set ifileContent [ifile get [HTTP::path]] }] } { HTTP::respond 404 content "File not found" } else { HTTP::respond 200 content $ifileContent unset ifileContent } }

You can also manage that files by command line or iControl.

 

References:

https://devcentral.f5.com/s/articles/syncing-local-repositories-with-ifiles-1082

https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/tmos-implementations-13-0-0/9.h...

https://clouddocs.f5.com/api/irules/iFile.html

 

Regards.

MABSJ
Nimbostratus
Nimbostratus

Hi cjunior!!

Thank you very much for your comment !!

Taking as an example this http://exmple.com/Common/file1

example.com is an Virtual Server in F5

and the file is in the path /etc/local/file1,

what would the irule be like? Because i have little experience about irules..

I understand that this irule would apply to this virtal server and before we need to create this ifile in this path too.

Best regards and thanks!!

cjunior
Nacreous
Nacreous

The ifile will work on stored files in BIG-IP system.

So, "/Common/file1" is a LTM file on partition Common wich refers to a imported file on BIG-IP system instead of Linux structure files. With iFile you can securely work with files and iRules.

So, instead of you write files on Linux, import it to BIG-IP. Then, you can automate to import files same as you copy it to Linux by command line.

 

Here a best explanation on how it works:

https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/tmos-implementations-13-0-0/9.h...

 

Regards.