Hosting static content in Azure Blob Storage
F5 NGINXaaS for Azure (NGINXaaS) can serve static content stored in Azure Blob Storage using private endpoints, ensuring maximum security by keeping your storage account completely inaccessible from the public Internet. This approach also eliminates the configuration payload size limitations of local hosting.
- An Azure Storage Account
 - An NGINXaaS for Azure deployment
 - A virtual network with available subnet space for private endpoints
 - Static content files to serve
 
Upload your static files to a container in your storage account. In this example, we’ll use a container named content.
- In your storage account, navigate to Networking under Security + networking.
 - Under Public network access, select Disable.
 - Click Save.
 
- In your storage account, navigate to Configuration under Settings.
 - Find the Allow Blob anonymous access setting and set it to Disabled.
 - Click Save.
 
- Navigate to Containers under Data management.
 - Select your container (for example, 
content). - Click Change access level.
 - Set Anonymous access level to Private (no anonymous access).
 - Click OK.
 
- Navigate to your virtual network where NGINXaaS is deployed.
 - Go to Subnets under Settings.
 - Click + Subnet.
 - Create a new subnet which will be used to assign IP address to your Private Endpoint NIC.
 - Make a note of the subnet name for the next step.
 
- In your storage account, navigate to Networking under Security + networking.
 - Go to the Private endpoint connections tab.
 - Click + Private endpoint.
 - Configure the private endpoint:
- Name: Provide a descriptive name for the private endpoint
 - Network Interface Name: Provide a name for the network interface
 - Target sub-resource: Select blob
 - Virtual network: Select the same virtual network as your NGINXaaS deployment
 - Subnet: Select the subnet created in the previous step
 - Private DNS integration: Enable this option to automatically create DNS records
 
 
- In your storage account, navigate to Shared access signature under Security + networking.
 - Configure the SAS token with minimal required permissions:
- Allowed services: Check Blob
 - Allowed resource types: Check Object
 - Allowed permissions: Check Read only
 - Start and expiry date/time: Set appropriate validity period
 - Allowed protocols: Select HTTPS only
 
 - Click Generate SAS and connection string.
 - Copy the SAS token (the part starting with 
?sv=). 
Store the SAS token securely and regenerate it regularly according to your security policies. Grant only the minimum permissions required for your use case.
Create an NGINX configuration that uses the private endpoint and SAS token to access your Azure Blob Storage. The following NGINX config points to the content directory with /static/ location and uses the SAS token from the previous step to authorize requests to blob storage. The resolver is set to 168.63.129.16 which is the Azure internal DNS IP. It doesn’t change. It resolves the storage account endpoint to the private endpoint IP configured earlier.
user nginx;
worker_processes auto;
worker_rlimit_nofile 8192;
pid /run/nginx/nginx.pid;
error_log /var/log/nginx/error.log error;
http {
    upstream storage_origin {
        server your-storage-account.blob.core.windows.net:443;
        keepalive 32;
    }
    resolver 168.63.129.16 valid=10s;
    server {
        listen 443 ssl;
        set $sas_token '?sv=YYYY-MM-DD&ss=b&srt=o&sp=r&se=YYYY-MM-DDTHH:MM:SSZ&st=YYYY-MM-DDTHH:MM:SSZ&spr=https&sig=YOUR_SAS_SIGNATURE_HERE';
        ssl_certificate /etc/nginx/example.cert;
        ssl_certificate_key /etc/nginx/example.key;
        location /static/ {
            rewrite ^/static/(.*)$ /content/$1 break;
            proxy_pass https://storage_origin$uri$sas_token;
            proxy_set_header Host your-storage-account.blob.core.windows.net;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
        }
    }
}Replace the following placeholders:
your-storage-accountwith your actual storage account nameYOUR_SAS_SIGNATURE_HEREwith your actual SAS token signature- Update the SAS token parameters according to your generated token
 
| Directive | Description | 
|---|---|
| upstream storage_origin | Defines the Azure Blob Storage endpoint as the backend server | 
| resolver 168.63.129.16 | Uses Azure’s internal DNS resolver to resolve the storage account to the private endpoint IP | 
| set $sas_token | Stores the SAS token for authorization | 
| rewrite | Maps the /static/ path to the /content/ container in blob storage | 
      
| proxy_pass | Forwards requests to the storage account with the SAS token appended | 
| keepalive 32 | Maintains persistent connections for better performance | 
Upload your NGINX configuration to your NGINXaaS deployment following the instructions in the NGINX configuration documentation.
- Go to 
https://<NGINXaaS IP>/static/<your-file-name>to access your static content. - For example, if you have an 
index.htmlfile in yourcontentcontainer, access it viahttps://<NGINXaaS IP>/static/index.html. - Your content should be served from Azure Blob Storage through the private endpoint.
 
You can verify that traffic flows through the private endpoint by checking that:
- The storage account is completely inaccessible from the public Internet
 - DNS resolution of your storage account resolves to the private IP address of the private endpoint
 - Network traffic flows through your virtual network without traversing the public Internet
 
- Maximum security: Storage account is completely private with no public Internet access
 - No payload size limits: Unlike local hosting, you’re not limited by the 3 MB configuration payload size
 - Scalable storage: Azure Blob Storage can handle large amounts of static content
 - Network isolation: All traffic flows through your private virtual network
 - Cost-effective: Azure Blob Storage offers cost-effective storage for static content
 - Controlled access: SAS tokens provide fine-grained access control with expiration
 
- SAS token management: Regularly rotate SAS tokens and grant minimal required permissions
 - Network isolation: Ensure private endpoints are properly configured in isolated subnets
 - Access monitoring: Enable logging and monitoring for storage account access
 - Principle of least privilege: Grant only the minimum permissions necessary for your use case
 
- Requires private endpoint configuration and additional subnet space
 - SAS tokens need regular rotation and management
 - Additional complexity compared to public access methods
 - Private endpoint incurs additional Azure networking costs