Forum Discussion

ccraddock's avatar
ccraddock
Icon for Cirrus rankCirrus
Sep 09, 2019

iRule assistance

Dear Community,

We ran into an issue last week where one of our app support members was logged into a production web portal (mistakenly thinking she was in the pre-production portal) and she made some changes in the production portal that caused an outage. Management has since asked if it would be possible to do the following:

-When a user is logged into a production portal (F5 Virtual Server with web tier pool behind it) from an internal IP address, that the F5 alter the HTTP response that places a transparent header for the user. The header might be something like "PRODUCTION PORTAL". They dont really want to have to alter the static content of the page, they would prefer to do this dynamically. This way when internal users are in the production portal that header will be there to remind them that they are in fact in the production portal. External users shouldnt see the transparent header because they arent coming from an internal IP address.

 

Is this possible with an iRule or other mechanism? Thanks for any feedback you can provide.

  • HI,

    You can achieve your need easly:

    first create a DG with your internal IP:

    Internal_user

    Then use this IP. if you come from internal network this irule inser a header with the following header:

    name: env

    value: prod

    when CLIENT_ACCEPTED {
    set header 0
    if { [class match [IP::client_addr] equals Internal_user] } {
    set header 1
    }
    }
     
    when HTTP_RESPONSE {
    if {$header}
    HTTP::header insert env prod
    }
    }

    keep me in touch

    regards

    • ccraddock's avatar
      ccraddock
      Icon for Cirrus rankCirrus

      Youssef,

       

      Thanks so much for the reply! I will try this out and let you know either today or Monday if it worked!

    • ccraddock's avatar
      ccraddock
      Icon for Cirrus rankCirrus

      Youssef,

       

      After trying out this iRule I think there may have been a miscommunication. On the HTTP Response I need something that will alter the HTML and add an HTML Header that says "PRODUCTION!" The HTTP Header is different from modifying the HTML in the response. I basically need an iRule or other policy that will edit the HTML in the response by adding "PRODUCTION!" to it. Is this possible?

       

      Thanks.

  • Hi,

     

    I understand your need. you were not talking about adding an HTTP header but a header in your web page.

    it means that you have to modify your page but in a controlled way.

     

    Example below: you will have to rewrite your response by adding needed style and contents in order to display Production Notification.

     

    <!DOCTYPE html>
    <html>
    <head>
    <style type="text/css">
    body { margin:0; }
    #titre { background: #fd0; width:100%; text-align:center; position: fixed; }
    </style>
    </head>
     
    <body>
    <div id="titre">PRODUCTION</div>
    <br>contents bla bla bla<br>
    </body>
     
    </html>

    If you show me your HTML application code I can help you to achieve your need.

     

    regards,

    • ccraddock's avatar
      ccraddock
      Icon for Cirrus rankCirrus

      Youssef,

       

      Here is the code for the login page. Once caveat is we would like this HTML text to be displayed on every page even after login. Is this possible?

       

      Thanks.

       

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

      "http://www.w3.org/TR/html4/loose.dtd">

      <html>

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

      <title>CEDAR Frontier - Login</title>

      <link href="/css/frontier.css" rel="stylesheet" type="text/css">

      <script type="text/javascript" LANGUAGE="JavaScript">

      function doload(){

      document.loginForm.username.focus();

      }

       

      function processSubmit()

      {

      var ef = document.loginForm;

      if((ef.username.value == null) || (ef.username.value == '')){

      alert("Please enter User ID");

      ef.username.focus();

      }

      else if((ef.userpassword.value == null) || (ef.userpassword.value == '')){

      alert("Please enter password");

      ef.userpassword.focus();

      }

      else{

      ef.submit();

      }

       

      }

       

      function handleKeydown(e)

      {

       if(!e)

        var e = window.event;

       

       key = e.keyCode;

       if(key == 13){

       processSubmit();

       }

      }

      document.onkeydown = handleKeydown;

       

      </script>

      </head>

      <body>

      <a name="top"></a>

      <div class="page">

       <table border="0" cellpadding="0" cellspacing="0" width="100%">

        <tbody>

         <tr>

          <td width="44%" valign="top"><a href="/"><img src="/images/logo.svg" style="height: 45px;" alt="Logo" class="logo"></a></td>

          <td width="46%">&nbsp;</td>

          <td width="10%" valign="top"><div class="markbox"><a href="http://www.cedardoc.com/" target="_blank"><img src="/images/PoweredBy_CEDAR.gif" alt="" border="0"></a></div></td>

         </tr>

        </tbody>

       </table>

       <br>

       <div class="navigation">

      <ul class="tierone">

         <li>&nbsp;</li>

        </ul>

      <ul class="tiertwo">

      <li>&nbsp;</li>

        </ul>

      </div>

       <div class="content">

        <table width="100%" border="0" cellspacing="0" cellpadding="0">

         <tr>

          <td width="50%" nowrap class="pagetitle">Welcome!</td>

          <td width="50%" align="right" nowrap></td>

         </tr>

         <tr>

          <td width="50%" nowrap class="subtitle">Log in</td>

          <td width="50%" align="right" nowrap></td>

         </tr>

        </table>

        <form name="loginForm" method="POST" action="/frontier/action/processLogin" onsubmit="javascript: return false">

         <input type="hidden" name="client_id" value="170">

         <table border="0" align="center" cellpadding="4">

          <tr>

           <td align="right"> User ID:</td>

           <td align="left"><input type="text" name="username"></td>

          </tr>

          <tr>

           <td align="right" valign="top">Password:</td>

           <td align="left" valign="top"><input type="password" name="userpassword" autocomplete="off">

            <br>

            <a href="/frontier/action/forgotPw?client_id=170" class="description">Forgot Password?</a> &nbsp;&nbsp;<a href="/frontier/action/forgotPw?client_id=170&actionType=showForgotUserId" class="description">Forgot User ID?</a> </td> 

          </tr>

          <tr>

           <td align="right">&nbsp;</td>

           <td align="left"></td>

          </tr>

          <tr>

           <td align="center">&nbsp;</td>

           <td align="center"><div class="buttonstyle">

             <div class="buttoneach"><a href="javascript:processSubmit()">Submit</a></div>

            </div></td>

          </tr>

         </table>

        </form>

        <p>&nbsp;</p>

       </div>

       <table width="100%" border="0" cellspacing="0" cellpadding="0">

        <tr>

         <td align="left" nowrap class="footermenu">&nbsp;</td>

         <td class="frontier">llFrontier by CEDAR document technologies</td>

        </tr>

       </table>

      </div>

      </body>

      </html>

    • ccraddock's avatar
      ccraddock
      Icon for Cirrus rankCirrus

       ,

       

      Any luck with the iRule? I know its a very complicated ask. Thanks.