# AVI Use Case Testing
###### tags: `AVI use case`, `how-to`
## Table of Content
[ToC]
## Lab Diagram - Physical

## Lab Diagram Logical

## Scenarios
1. SSL bridging Use case with two-way ssl with Http context path modification with custom persistence .
2. Use case scenario with Custom http Request rewriting for client and http header modification for server side. http-x-forward function to be enabled
4. Explicit Proxy use case for Avi
5. Use case with SNI based URI routing with Custom snat IP address for different Pool
6. GSLB + AVI Load balancer use case with Geo Proximity with Fall back Pool
7. AVI Load balancer use case with support for WebSocket protocol with FQDN pool member
8. Layer 4 Load balancing without SNAT
## 1. SSL Bridging
This scenario involves a two-way SSL (client side and server side) with HTTP context path modification and custom persistence
### Enable two-way SSL (client side and server side)
Enable SSL on Virtual Service (Client side)

Enable SSL on Pool (server side)

### Create HTTP context path modification
Edit the HTTP Request policy in the Virtual Service, choose the match (in this case: Path)

Choose the action (in this case: Content Switch)

Choose the other pool to switch into, you can create new pool as well.

### Create Custom Persistence
Persistence profile can be attached to the pool

You can create custom profile based on specific app cookie or custom HTTP header

## 2. Custom HTTP Request Rewriting
This scenario is a custom HTTP request rewriting for client and HTTP header modification for server side.
### Create Custom HTTP Request Rewrite
The options for match:
- Client IP
- Service Port
- Protocol type
- HTTP Method
- Path
- Query
- Headers
- Cookie
- Host Header

For action, you have options to modify the header or to rewrite the path

### Adding x-forwarded-for
Adding the x-forwarded-for is available in the application profile attached to the Virtual Service. In this case it's HTTPS application profile. In this HTTP profile, you have option to enable:
- Connection multiplex
- X-forwarded-for
- Read true Client IP in HTTP header
- Enforce HTTPS by redirecting or inserting HSTS response
- Do client SSL certificate validation (in HTTPS app profile)
- Enable compression and caching
- Configure DDoS profile such as rate limit or timeout settings


## 3. Explicit Proxy
AVI does not do forward proxy
## 4. SNI based URI routing
This scenario is a Virtual service which has routing based on Server Name Indication (SNI) and custom SNAT IP for different pool
### Create Parent VS
The configuration for SNI based routing is using parent-child concept.
The parent VS will receive all new client connection and will do internal handoff to the child VS with specified SNI. The parent VS will logs the TCP and SSL handshake.
The parent VS can also be configured with wildcard SSL certificate. SSL certificate configured in parent VS will be used if the client does not send an SNI hostname TLS extension or if the client's TLS SNI hostname does not match any of the child's VS domain name.
More details: [here](https://avinetworks.com/docs/latest/server-name-indication/)
Here is example of creating parent VS

### Create Child Virtual Service with SNI Certificate (if available)

### Using custom SNAT IP address for server connection
By default, AVI will use the SE IP (self ip) as SNAT to the server. This can be changed into:
- VIP address as SNAT or
- Custom SNAT address
The configuration is per VS basis, so it is available in the VS configuration like below

## 5. GSLB With Geo-proximity
This scenario is creating GSLB service with geolocation based algorithm and fall back pool.
### Enabling Geo Profile
AVI has built-in Geo DB files in the controller. However, custom geo-db file can be uploaded into the controller.

Create geo profile to attached the geo-db file.

### Configuring GSLB Service with Geo-location Algorithm
In the GSLB service (wide ip) configuration, you can use Geo location-based algorithm for specific GSLB service (wide ip).

You can configure pools for the GSLB service. Notice that within the pool, you can specify load balancing algorithm. This is the algorithm within the pool member. If you have multiple local DC within the same region (like different AZs), this is the algorithm used for this GSLB pool group.

### Configuring fall back
You can configure fallback IP in the case of failure for all VS configured in the pool member. GSLB will response with this IP address for the DNS queries.

## 6. Websocket Protocol
Enabling VS with websocket protocol support can be done from the HTTP/HTTPS profile

### FQDN Pool Member
In pool configuration, you can insert FQDN of the servers by inserting it in the "Server IP Address" column. It will resolve using local DNS server. Local DNS server is configured during the first initialization of Controller. DNS configuration can be found in the Administration - Settings - DNS/NTP


## 7. Layer 4 Load Balancing Without SNAT
You can disable SNAT by using Auto Gateway feature

This Auto Gateway works similarly like Auto Last Hop feature from LTM.