Jump to content
Welcome to our new Citrix community!
  • Configure NetScaler WAF for Azure Web App


    cugcblogs

    saadallahchebarornd.jpg by Saadallah Chebaro, CTA, UAE CUGC Leader

    Introduction:

    Just when I thought I had it all figured out, Citrix NetScaler on Microsoft Azure gives me a reality check–proving to be a worthy adversary and a true nemesis. Having spent so much time on the HA part of NS on Azure, now is the time to dive into real-world scenarios involving advanced features, that being WAF “Web Application Firewall” use-cases on Azure with PaaS offerings aka. Web Apps.

    Citrix NetScaler platinum offers WAF capabilities that can be applied to published virtual servers on the appliance itself, which works the same as on-premises or on-Azure, since IaaS machines can be simply added as a LB virtual server on the appliance in the same manner that on-premises VMs/Servers are added.

    On Microsoft Azure cloud though, the Web App "Platform as a Service" offering allows organizations to host web applications directly on the cloud, utilizing a pre-built infrastructure environment that is maintained by Azure. This relieves you of the burden of having to build, configure, support, scale, and maintain backend infrastructure to host your web applications.

    That sounded great, until my colleague Shejoor, received a requirement to configure WAF for Azure Web Apps using Citrix NetScaler, which clearly states on its Azure Marketplace that the service is fully supported on the cloud. Needless to say, documentation did not exist for this specific requirement, so after a week of work into it, here is how to get this working the right way.

    chebaro080618-02.png.05856ed17976206a72fe645a2f48fc93.png

    Microsoft Azure has two approaches when it comes to creating App Services, each serves a different requirement:

    • Web Apps

    Directly create a web app service, upload your website content, and publish the same. Custom domains and custom SSL certs can be added to this service. A content delivery network can also be added to this web app and, most importantly, restrictions can be applied for accessibility to this service IP-based.

    Downside here is that Web Apps are deployed with an Azure-provided public IP only and thus are created toward external access with no internal network functionality, which is a major show-stopper when it comes to our scenario: WAF with NetScaler for Web App Service. Unfortunately, our customer had this exact same scenario and I will detail how to make this work. But, it is not the optimal configuration, nor the recommended one.

    https://docs.microsoft.com/en-us/azure/app-service/app-service-web-overview

    In order to configure this with a direct Web App deployment, the following has to be done to overcome the challenges that an out-of-the-box approach would present:

    • Add and Verify a custom domain to the Web App Service.
    • Assign a custom SSL certificate to the Web App Service.
    • Assign a Public IP to the Subnet IP SNIP of the NetScaler.
    • Create an LB server with WAF policy applied and point to Web App Service.
    • Delete CName record that was used to verify custom Web App domain and create an A record with same custom domain pointing to NetScaler VIP for that service.
    • Disable HTTP on Web App Service and only allow HTTPS.
    • Apply restriction on Web App and only allow access to NetScaler SNIP IP (All NS SNIPs if in HA mode).

    The downside of this approach is that all traffic will be going from the SNIP public IP to reach the Web App (since the Web App only has a public IP, thus we had to add a public IP to the NetScaler SNIP) and not communicate internally using Azure backend network which would be considered as outbound traffic, and Azure will charge you for all that traffic. Also, this approach requires HTTPS with custom domain and SSL cert, as HTTP will not work between NetScaler and Web App. This approach is not recommended for high traffic Web Apps.

    • App Service Environment

    ASE creates a fully isolated and dedicated environment for securely running App Service apps at high scale. Create an App Service Environment and, inside that, create a Web App exactly as the first approach but one that would be hosted under the ASE. ASE can be configured with an external public VIP or an internal VIP connected to an Azure vNET. Because Internal ASE can have an internal IP (utilizes Azure Internal Load Balancer) that is hosted on a vNET, which, in turn can communicate internally with other Azure IaaS services, thus making it the recommended way to go.

    NetScaler on Azure is an IaaS VM and is thus connected to a vNET which, in turn, has IPs that can be configured to communicate with an Internal App Service Environment that has a Web App configured. This would allow us to apply restrictions on the Web App to only allow traffic from NetScaler to force users to use the LB virtual server that has WAF applied to connect to the Web App. That is not possible with standard direct Web App deployment.

    https://docs.microsoft.com/en-us/azure/app-service/environment/create-ilb-ase

    In order to configure this with an Internal App Service deployment, the following has to be done to overcome the challenges that an out-of-the-box approach would present:

    • Build the ASE with an internal VIP on a vNET that is peered with NetScaler vNET in the same region.
    • Add and Verify a custom domain to the Web App Service under ASE.
    • Assign a custom SSL certificate to the Web App Service under ASE.
    • Create an LB server with WAF policy applied and point to Internal ASE ALB IP.
    • Delete CName record that was used to verify custom Web App domain and create an A record with same custom domain pointing to NetScaler VIP for that service.
    • Disable HTTP on Web App Service and only allow HTTPS.
    • On the NSG applied to the vNET of the Internal ASE, apply an allow rule from the NetScaler Subnet IP and block all other traffic. That is why we built the ASE on a seperate vNET because the NSG has to be applied to the whole vNET subnet not on the ASE directly.

    The upside with this approach is that no public IP is required on NetScaler and communication is using Azure backbone internally, so no additional charges and no foreseen bandwidth limitations or performance issues since its on the same network logically. This is the recommended approach and the right way to do it.

    Now, ASE is not cheap, and I could not add a service on my subscription, so cannot document this in my lab and with no customer consent, I won't be able to show this (although I will show the first type deployment which has some similar steps and required more out-of-the-box thinking to get it working).

    Configuration:

    1- Create a Web App Service and a static HTTP site for testing (click to enlarge images):

    chebaro080618-03.jpeg.3d04de3c09d89b06c4306b578c21d88c.jpegchebaro080618-04.jpeg.3ac495a32103a23682899ab3aff00a94.jpegchebaro080618-05.jpeg.cbf6ccb83f2d11b542d1b323da02a553.jpeg

    Accessing the Azure-hosted URL on HTTP and HTTPs shows the following out of the box page.

    chebaro080618-06.jpeg.aa61741b274d39eaad68b57777734dd6.jpeg

    Make sure that the service plan is not Dev/Test, so that a custom domain and SSL cert can be added for the Web App.

    chebaro080618-07.jpeg.0fde906217cb6ee964cb6d5561ab0606.jpeg

    I have deleted the above and created one using Cloud Shell with a static HTTP site ( Deleted the above to have the same name "netscaler").

    chebaro080618-08.jpeg.6c4825b5bd8b3860973d43718ca60a9b.jpegchebaro080618-09.jpeg.1b56edfeaf61755119efa762bf2eee8d.jpeg

    2- Add a custom domain, SSL certificate, and apply HTTPS Only to Web App:

    chebaro080618-10.jpeg.677f924942c53efcdc932863f595c753.jpeg

    The reason I am showing this configuration is that because out-of-the-box, when using a custom domain, the A record with custom domain, cert, and IP SSL binding, is that the records must point to Azure-hosted public IP of Web App. So, how can NetScaler LB be configured with WAF applied in this scenario? If a NetScaler LB server is created and a subdomain mapped to it, without that subdomain being verified under Azure Web App although pointing to the Azure provided URL through the NS VIP, it won't work. The trick here is that Azure only uses these records for verification, and after that has been done, they can be changed to point to the NetScaler LB server, which would then work only when using custom domain with IP SSL binding (took me a week to figure this out).

    chebaro080618-11.jpeg.bb72a1d5d930a2d0f64625283101df66.jpegchebaro080618-12.jpeg.5fa73cdf6ce601054756c230d7473718.jpegchebaro080618-13.jpeg.97600b9e74188be1b9e7603154ae2dd2.jpegchebaro080618-14.jpeg.a4d8575f90e255a28202e3861eab299a.jpegchebaro080618-15.jpeg.c471bc2ce933c0080ce5b53c1f1f56fd.jpegchebaro080618-16.jpeg.ff8c1025f88df9441cf1671207024ef6.jpegchebaro080618-17.jpeg.90f14ad16a35cc328c21766de41e5a14.jpegchebaro080618-18.jpeg.5df6571cf028be1440ad8a39ef20f7b0.jpeg

    After Applying an IP-Based SSL binding, the public IP changes for the Web App so that in normal conditions, one would change this in the public DNS for the custom URL to work. But for us, no change as of now, since our subdomain is verified and in the near future after NS is configured, we will point this subdomain to the public IP of the NS VIP used to load balance this Web App and apply WAF policies on that virtual server.

    chebaro080618-19.jpeg.96dd4e3e3870f0c5936b44603d0febcc.jpeg

    Delete all related records to that subdomain, as later on, we will add only an A record for our custom subdomain pointing to the NS VIP public IP that is hosting that service.

    chebaro080618-20.jpeg.43041b889b6cd9d21befd2d5c92fb925.jpeg

    3- Configure a load balancing virtual server on NetScaler for this Web App and apply WAF policy and Web App IP Restriction:

    Remember to add a public IP to the Subnet IP:

    chebaro080618-21.jpeg.a200448e490347eaf856b059d3e42c58.jpeg

    Server must point to the Azure-provided URL, not custom URL:

    chebaro080618-22.jpeg.995419ce7c66deb2b1b1ad6d03372d9d.jpegchebaro080618-24.jpeg.12b3c372915addac6774f341df711b62.jpegchebaro080618-25.jpeg.63e8375476593c02650107a507d6bcb1.jpegchebaro080618-26.jpeg.87e973c64bffd014ad85a5bc362c9b0e.jpegchebaro080618-27.jpeg.596f4befceea12f43a81d4c88a3cd5c2.jpegchebaro080618-28.jpeg.d92ce6f2d61aa0796386b6849078ed98.jpeg

    Apply WAF policy on this virtual server:

    chebaro080618-29.jpeg.9625c4b71c2c02eb9ee231419c9468e2.jpeg

    Create an A record for the custom domain previously added to Web App that points to the public IP assigned to the NS virtual LB server that has WAF enabled:

    chebaro080618-30.jpeg.483c91e9df3babe0848d98182595ce6d.jpeg

    Test access to custom domain (which now is going through NS):

    chebaro080618-31.jpeg.509d81a3d7ea37c860e716e11bc4a181.jpeg

    IP restrictions will be added to only allow SNIP public IP to access this Web App Service (this would prevent users from accessing the Azure-provided URL and bypassing the NS LB URL which has WAF enabled):

    chebaro080618-32.jpeg.c43eca04b883a14a4416d305050cd9b8.jpegchebaro080618-33.jpeg.9880d0180b126733bd6b4d6a2aa02ddb.jpeg

    Access to the Azure-provided URL is now blocked from ALL IPs except NetScaler SNIP public IP:

    chebaro080618-34.jpeg.839b34792527b3ac0578c59f74a840fe.jpeg

    Conclusion:

    Internal ASE is the recommended way to go forward when wanting to deploy WAF the right way for a Web App, yet the direct configuration does work with the listed "before considerations and short comings." If I get access to an ASE environment, I will document the same though for the most part, the difference would be an Internal ASE would have an internal IP rather than a web URL to load balance, and restrictions would apply to allow SNIP internal IP rather than having to assign a public IP for the same in a standard Web App NS WAF approach. Let me know your thoughts.

    Zero To Hero Blog

    martinzugecround.png.636b4c0d2fdbc6cfe9d0e434a903414c.png


    User Feedback

    Recommended Comments

    Guest Looking Back Over 2018 – A Lot of Great Content for CUGC! – BLOGS

    Posted

    […] CTA and UAE leader Saadallah Chebaro wrote a lengthy how-to on Configuring NetScaler WAF for Azure Web App. […]
    Link to comment
    Share on other sites



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...