|  | 
|  | 1 | +--- | 
|  | 2 | +title: Hosting static content in Azure Blob Storage | 
|  | 3 | +weight: 210 | 
|  | 4 | +toc: true | 
|  | 5 | +nd-docs: DOCS-1344 | 
|  | 6 | +url: /nginxaas/azure/quickstart/hosting-static-content-blob-storage/ | 
|  | 7 | +type: | 
|  | 8 | +- how-to | 
|  | 9 | +--- | 
|  | 10 | + | 
|  | 11 | +F5 NGINXaaS for Azure (NGINXaaS) can serve static content stored in Azure Blob Storage, allowing you to host large static websites without the configuration payload size limitations of local hosting. This approach also keeps your storage account private by restricting access to your NGINXaaS deployment. | 
|  | 12 | + | 
|  | 13 | +## Prerequisites | 
|  | 14 | + | 
|  | 15 | +- An Azure Storage Account | 
|  | 16 | +- An NGINXaaS for Azure deployment | 
|  | 17 | +- Static content files to serve | 
|  | 18 | + | 
|  | 19 | +## Configure Azure Blob Storage | 
|  | 20 | + | 
|  | 21 | +### Step 1: Upload static files to the $web container | 
|  | 22 | + | 
|  | 23 | +Place your static files in the `$web` container in your storage account. This is the standard container used for static website hosting in Azure. | 
|  | 24 | + | 
|  | 25 | +### Step 2: Configure network access | 
|  | 26 | + | 
|  | 27 | +1. In your storage account, navigate to **Networking** under **Security + networking**. | 
|  | 28 | +2. Under **Public network access**, select **Enable public access from selected virtual networks and IP addresses**. | 
|  | 29 | +3. In the **Virtual networks** section, click **Add existing virtual network**. | 
|  | 30 | +4. Select the virtual network and subnet where your NGINXaaS deployment is located. | 
|  | 31 | +5. Click **Add** to allow your NGINXaaS deployment to connect to the storage account. | 
|  | 32 | + | 
|  | 33 | +{{< call-out "note" >}}This configuration ensures that your storage account is not accessible from the public Internet, only from your NGINXaaS deployment's subnet.{{< /call-out >}} | 
|  | 34 | + | 
|  | 35 | +### Step 3: Enable static website hosting | 
|  | 36 | + | 
|  | 37 | +1. In your storage account, navigate to **Static website** under **Data management**. | 
|  | 38 | +2. Enable **Static website**. | 
|  | 39 | +3. Set your **Index document name** (e.g., `index.html`). | 
|  | 40 | +4. Optionally, set an **Error document path** for 404 errors. | 
|  | 41 | +5. Click **Save**. | 
|  | 42 | + | 
|  | 43 | +Note the **Primary endpoint** URL that appears after enabling static website hosting. You'll need this for your NGINX configuration. | 
|  | 44 | + | 
|  | 45 | +## Configure NGINXaaS | 
|  | 46 | + | 
|  | 47 | +Create an NGINX configuration that proxies requests to your Azure Blob Storage static website endpoint: | 
|  | 48 | + | 
|  | 49 | +```nginx | 
|  | 50 | +user nginx; | 
|  | 51 | +worker_processes auto; | 
|  | 52 | +worker_rlimit_nofile 8192; | 
|  | 53 | +pid /run/nginx/nginx.pid; | 
|  | 54 | +
 | 
|  | 55 | +error_log /var/log/nginx/error.log error; | 
|  | 56 | +
 | 
|  | 57 | +http { | 
|  | 58 | +    upstream storage_origin { | 
|  | 59 | +        server your-storage-account.z20.web.core.windows.net:443; | 
|  | 60 | +        keepalive 32; | 
|  | 61 | +    } | 
|  | 62 | +
 | 
|  | 63 | +    server { | 
|  | 64 | +        listen 443 ssl; | 
|  | 65 | +        ssl_certificate /etc/nginx/example.cert; | 
|  | 66 | +        ssl_certificate_key /etc/nginx/example.key; | 
|  | 67 | +
 | 
|  | 68 | +        location /static/ { | 
|  | 69 | +            proxy_pass https://storage_origin/content/; | 
|  | 70 | +            proxy_set_header Host your-storage-account.z20.web.core.windows.net; | 
|  | 71 | +            proxy_http_version 1.1; | 
|  | 72 | +            proxy_set_header Connection ""; | 
|  | 73 | +        } | 
|  | 74 | +    } | 
|  | 75 | +} | 
|  | 76 | +``` | 
|  | 77 | + | 
|  | 78 | +{{< call-out "important" >}}Replace `your-storage-account` with your actual storage account name in both the upstream server definition and the `proxy_set_header Host` directive. The region code (e.g., `z20`) may vary depending on your storage account's region.{{< /call-out >}} | 
|  | 79 | + | 
|  | 80 | +### Configuration breakdown | 
|  | 81 | + | 
|  | 82 | +- **upstream storage_origin**: Defines the Azure Blob Storage static website endpoint as the backend server | 
|  | 83 | +- **keepalive 32**: Maintains persistent connections to the storage endpoint for better performance | 
|  | 84 | +- **location /static/**: Maps the `/static/` path on your NGINXaaS deployment to the `/content/` path in your static website | 
|  | 85 | +- **proxy_pass**: Forwards requests to the Azure Blob Storage endpoint with the `/content/` path | 
|  | 86 | +- **proxy_set_header Host**: Sets the correct Host header for the storage account | 
|  | 87 | +- **proxy_http_version 1.1**: Uses HTTP/1.1 for better connection reuse | 
|  | 88 | +- **proxy_set_header Connection ""**: Clears the connection header for proper keepalive behavior | 
|  | 89 | + | 
|  | 90 | +## Upload the configuration | 
|  | 91 | + | 
|  | 92 | +Upload your NGINX configuration to your NGINXaaS deployment following the instructions in the [NGINX configuration]({{< ref "/nginxaas-azure/getting-started/nginx-configuration/nginx-configuration-portal.md" >}}) documentation. | 
|  | 93 | + | 
|  | 94 | +## Test the configuration | 
|  | 95 | + | 
|  | 96 | +1. Browse to `https://<NGINXaaS IP>/static/<your-file-name>` to access your static content. | 
|  | 97 | +2. For example, if you have an `index.html` file in your `$web` container, access it via `https://<NGINXaaS IP>/static/index.html`. | 
|  | 98 | +3. Your content should be served from Azure Blob Storage through your NGINXaaS deployment. | 
|  | 99 | + | 
|  | 100 | +## Verify traffic routing | 
|  | 101 | + | 
|  | 102 | +You can verify that requests are properly routed through your NGINXaaS deployment by checking the Azure Storage logs: | 
|  | 103 | + | 
|  | 104 | +1. Enable logging for your storage account if not already enabled. | 
|  | 105 | +2. In the storage logs, you should see requests coming from the private IP address of your NGINXaaS deployment, not from public Internet addresses. | 
|  | 106 | + | 
|  | 107 | +## Benefits of this approach | 
|  | 108 | + | 
|  | 109 | +- **No payload size limits**: Unlike local hosting, you're not limited by the 3 MB configuration payload size | 
|  | 110 | +- **Scalable storage**: Azure Blob Storage can handle large amounts of static content | 
|  | 111 | +- **Private access**: Your storage account remains private and is only accessible through your NGINXaaS deployment | 
|  | 112 | +- **Cost-effective**: Azure Blob Storage offers cost-effective storage for static content | 
|  | 113 | +- **Global availability**: Leverage Azure's global infrastructure for content delivery | 
|  | 114 | + | 
|  | 115 | +## Limitations | 
|  | 116 | + | 
|  | 117 | +- Requires network connectivity between your NGINXaaS deployment and the storage account | 
|  | 118 | +- Additional latency compared to locally hosted content due to the proxy pass to Azure Blob Storage | 
|  | 119 | +- Storage account must be in a region that allows network connectivity to your NGINXaaS deployment | 
0 commit comments