---
title: Nginx-VPP Case
slug: routing/nginx-vpp-case
createdAt: 2026-05-08T08:37:49.057Z
---

# <font color="#1d50a2">**Introduction**</font>

This guide provides step-by-step instructions for deploying Nginx services on the Asterfusion Open Intelligent Gateway running AsterNOS-VPP. Leveraging Asterfusion's unique **LDP (LD\_PRELOAD)** architecture, AsterNOS achieves 100% compatibility with native Nginx configurations while delivering extreme concurrency performance through the VPP user-space data plane and hardware-accelerated crypto offloading.

## <font color="#1d50a2">**What This Guide Will Accomplish**</font>

- **Scenario 1: Native Static Web Server** – Utilizing the gateway's local storage (NVMe/eMMC) to provide high-performance file hosting services.
- **Scenario 2: High-Performance L7 Reverse Proxy** – Acting as an application-aware intermediary to forward traffic to backend server pools.
- **Scenario 3: HTTPS & SSL Termination** – Terminating SSL/TLS securely at the gateway edge to simplify centralized certificate management and relieve backend computational workloads.
- **Scenario 4: Upstream Load Balancing** – Distributing incoming traffic across multiple real backend nodes for high availability.

***

# <font color="#1d50a2">**Network Planning &amp; Global Configuration**</font>

Before deploying specific business scenarios, the underlying network and global Nginx parameters must be initialized.

## <font color="#1d50a2">**Network Topology Plan**</font>

![](https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/r3rjnaxYELv184cYeC91B-20260508-085742.png)

| **Device / Interface** | **IP Address / Mask** | **Role Description**                   |
| ---------------------- | --------------------- | -------------------------------------- |
| AsterNOS (Eth1)        | 192.168.1.166/24      | WAN Port (Receives client requests)    |
| AsterNOS (Eth2)        | 172.16.10.1/24        | LAN Port (Connects to backend servers) |
| Backend Server         | 172.16.10.100/24      | Business server hosting actual content |

## <font color="#1d50a2">**Global Nginx Service Initialization**</font>

Enter the SONiC CLI to start the Nginx process and isolate CPU cores to ensure maximum data plane performance.

:::BlockQuote
sonic# configure terminal
 <font color="#5fd74e"># 1. Start the Nginx core process</font>
sonic(config)# nginx start
 <font color="#5fd74e"># 2. Configure performance parameters (based on standard test specifications)</font>
sonic(config)# nginx worker\_connections 1500
sonic(config)# nginx keepalive\_timeout 80
 <font color="#5fd74e"># 3. Isolate CPU cores\: Allocate 2 cores to Nginx, keep VPP in auto-adaptation mode</font>
sonic(config)# cpu\_core nginx\_num 2 vpp\_num auto
 <font color="#5fd74e"># 4. Apply global settings and save</font>
sonic(config)# nginx reload
sonic(config)# exit
sonic# write
:::

***

# <font color="#1d50a2">**Scenario 1\: Native Static Web Server**</font>

This scenario demonstrates how AsterNOS serves local files through the VPP-LDP path directly to external clients.

## <font color="#1d50a2">**P**</font><font color="#1d50a2">**repare Persistent Files**</font>

:::hint{type="info"}
***Note:***&#x20;

&#x20;Since AsterNOS Nginx runs within a Docker container, only directories under `/etc/sonic/` are persistently mounted into the container's file system. Files placed elsewhere may be inaccessible to Nginx.
:::

```bash
# Enter the Linux bash terminal of the device
admin@sonic:~$ sudo mkdir -p /etc/sonic/nginx_mmc
admin@sonic:~$ sudo bash -c 'echo "<h1>Success! AsterNOS Static Web Server is ALIVE!</h1>" > /etc/sonic/nginx_mmc/index.html'
```

## <font color="#1d50a2">**Configure and Deploy Static Web**</font>

Create the `static_web.conf` file on the host.

```nginx
# content of /home/admin/static_web.conf
server {
    listen 8081;   # Use a dedicated port to avoid management web conflicts
    server_name AsterNOS; # Catch-all wildcard for testing

    location / {
        root /etc/sonic/nginx_mmc;  # Points to the container-visible mount point
        index index.html;
    }
}
```

Apply the configuration using AsterNOS specific commands:

:::BlockQuote
sonic(config)# nginx update server /home/admin/static\_web.conf
sonic(config)# nginx reload
:::

## <font color="#1d50a2">**Verif**</font><font color="#1d50a2">**y the Service**</font>

1. **Client Test:** Execute a request from an external client:
   `curl -v http://192.168.1.166:8081`
2. **Expected Result:** The terminal should display the "Success! AsterNOS Static Web Server is ALIVE!" text with an `HTTP/1.1 200 OK` status.

::Image[]{src="https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/m8OPb-jWloO6Kni3Gg8Nq-20260508-093743.png" size="100" width="798" height="460" position="center" darkWidth="798" darkHeight="460" showCaption="false" indent="1"}

***

# <font color="#1d50a2">**Scenario 2\: High-Performance L7 Reverse Proxy**</font>

Reverse Proxy is the most common gateway deployment. AsterNOS intercepts external traffic and transparently forwards it to the internal backend (`172.16.10.100`).

:::hint{type="warning"}
***Note:***&#x20;

Please avoid having multiple server blocks listening on the same port to prevent traffic conflicts.You can view the current configuration of Nginx by using the`show nginx status`command.

If a previous configuration occupies the target port, remove it first using the `delete` command:

`sonic(config)# nginx delete server /home/admin/static_web.conf`
:::

## <font color="#1d50a2">**Configure and Deploy Reverse Proxy**</font>

Prepare `proxy.conf` following the official test case syntax:

```nginx
server {
    listen 8080;
    server_name AsterNOS;

    location ^~/ {
        proxy_pass http://172.16.10.100:80;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
```

Update and reload:

:::BlockQuote
sonic(config)# nginx update server /home/admin/proxy.conf
sonic(config)# nginx reload
:::

## <font color="#1d50a2">**Verify**</font><font color="#1d50a2"> **the Service**</font>

1. **Start Backend Service:** Run `sudo python3 -m http.server 80` on backend server(`172.16.10.100`).
2. **Client Test:** Run `curl -v http://192.168.1.166:8080`.
3. **Backend Log Check:&#x20;**&#x52;eturn to the backend server's terminal. You should see the access log generated by the Python HTTP server. `172.16.10.1 - - "GET / HTTP/1.1" 200 -`   .

::Image[]{src="https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/gkvzoqdh-h8Mcw7hnejmU-20260509-035921.png" size="100" width="898" height="96" darkWidth="898" darkHeight="96" position="center" showCaption="false" indent="1"}

***

# <font color="#1d50a2">**Scenario 3\: HTTPS &amp; Certificate Management (SSL Termination)**</font>

In a typical enterprise environment, backend application servers should not be burdened with managing certificates across dozens of internal nodes.

AsterNOS serves as a **unified secure boundary**, terminating HTTPS traffic at the edge (SSL Termination) and proxying plain HTTP to the backend. It also provides a simplified CLI for persistent certificate management inside the containerized environment.

## <font color="#1d50a2">**Upload**</font> <font color="#1d50a2">**SSL Certificates**</font>

Do **not** manually copy certificates into the Linux file system, as the Nginx process runs inside an isolated container. Use the native SONiC CLI to import them into the persistent vault.

Assuming you have uploaded your commercial certificate (`asterfusion.crt`) and private key (`asterfusion.key`) to `/home/admin/`:

:::BlockQuote
<font color="#5fd74e"># The system will automatically mount these to /etc/sonic/nginx/cert/ inside the container</font>
sonic(config)# nginx update cert /home/admin/asterfusion.crt
sonic(config)# nginx update cert /home/admin/asterfusion.key
:::

## <font color="#1d50a2">**Configure H**</font><font color="#1d50a2">**TTPS Proxy**</font>

Create a new configuration file (e.g., `https_proxy.conf`) using the standardized certificate paths.

```nginx
# content of /home/admin/https_proxy.conf
server {
    listen 8443 ssl default_server;
    server_name AsterNOS;

    # Core: Point to the system-managed certificate vault
    ssl_certificate      /etc/sonic/nginx/cert/asterfusion.crt;
    ssl_certificate_key  /etc/sonic/nginx/cert/asterfusion.key;

    location ^~/ {
        proxy_pass http://172.16.10.100:80;
        
        # Pass essential headers to the backend
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme; # Tells backend the original request was HTTPS
    }
}
```

## <font color="#1d50a2">**Deploy** </font><font color="#1d50a2">**Configuration**</font>

Apply the HTTPS proxy configuration and reload the service.&#x20;

:::BlockQuote
sonic(config)# nginx update server /home/admin/https\_proxy.conf
sonic(config)# nginx reload
:::

## <font color="#1d50a2">**Verif**</font><font color="#1d50a2">**y the Service**</font>

1. **Client Test:** Run`curl -v -k https://192.168.1.166:8443`
2. **Expected Result:** A successful TLS handshake (`SSL connection using TLSv1.3`) followed by an `HTTP/1.1 200 OK` response with the backend content. The backend server logs will show a standard HTTP connection.

::Image[]{src="https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/wHsL8CySYAnYG8j6mt7ww-20260509-075539.png" size="100" width="1099" height="830" darkWidth="1099" darkHeight="830" position="center" showCaption="false" indent="1"}

***

# <font color="#1d50a2">**Scenario 4\: Upstream Load Balancing (with Advanced Strategies)**</font>

In a real-world production environment, critical applications are rarely hosted on a single server. To ensure high availability (HA) and distribute high-concurrency workloads, organizations deploy multiple identical backend servers.

AsterNOS natively supports Nginx's `upstream` module, allowing the gateway to act as an intelligent Layer 7 load balancer. It distributes incoming traffic across a pool of real backend nodes using various scheduling algorithms.

## <font color="#1d50a2">**C**</font><font color="#1d50a2">**onfigure Upstream Pool**</font>

In this scenario, assume you have three backend business servers located at `172.16.10.101`, `172.16.10.102`, and `172.16.10.103`.

![](https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/xpfi16xh3TyqpoHENYBPs-20260509-080037.png)

Create a configuration file (e.g., `load_balancer.conf`). The default distribution method is **Round Robin**, which distributes requests sequentially and evenly.

```nginx
# content of /home/admin/load_balancer.conf

# 1. Define the pool of real backend servers
upstream enterprise_backend_pool {
    server 172.16.10.101:80;
    server 172.16.10.102:80;
    server 172.16.10.103:80;
}

# 2. Define the gateway's proxy behavior
server {
    listen 8080 default_server;
    server_name AsterNOS;

    location ^~/ {
        proxy_pass http://enterprise_backend_pool;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
```

## <font color="#1d50a2">**Deploy Configuration**</font>

Apply the configuration. Always use **absolute paths** to avoid directory context errors:

:::BlockQuote
sonic# configure terminal
 <font color="#5fd74e"># Apply the new Load Balancer configuration</font>
sonic(config)# nginx update server /home/admin/load\_balancer.conf
sonic(config)# nginx reload
:::

## <font color="#1d50a2">**Verif**</font><font color="#1d50a2">y the Service</font>

Run `curl -s http://192.168.1.166:8080` multiple times. You will see responses alternately and evenly coming from Node 101, 102, and 103.

![](https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/38t9Sjhpy5yMaHs_uv-FM-20260509-080244.png)

## <font color="#1d50a2">**Advanced\: Weighted Round Robin**</font>

When backend servers have different hardware specifications, you can assign weights to distribute traffic proportionally.

To make the first node process 3 times more traffic than the others, modify the `upstream` block in your file:

```nginx
upstream enterprise_backend_pool {
    server 172.16.10.101:80 weight=3; # Receives 60% of traffic
    server 172.16.10.102:80 weight=1; # Receives 20% of traffic
    server 172.16.10.103:80 weight=1; # Receives 20% of traffic
}
```

*Reload Nginx, and execution results will show a 3:1:1 request distribution ratio.*

![](https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/9YZUHG7r3jtpqeE3df1fy-20260509-082053.png)

## <font color="#1d50a2">**Advanced\: IP Hash**</font>

For stateful applications (e.g., shopping carts, user logins), ensuring a specific client always reaches the same backend server is critical.

Add the `ip_hash` directive to bind the client's IP to a specific node:

```nginx
upstream enterprise_backend_pool {
    ip_hash; # Enable session persistence
    server 172.16.10.101:80;
    server 172.16.10.102:80;
    server 172.16.10.103:80;
}
```

*Reload Nginx, and multiple requests from the same client IP will consistently be routed to the exact same backend server.*

![](https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/p9BJ1TqWsGTXt5p_chp_S-20260509-082213.png)

***

# <font color="#1d50a2">**Conclusion**</font>

This guide has successfully demonstrated the comprehensive Layer 7 application delivery capabilities of AsterNOS-VPP. By walking through real-world scenarios—from basic static file hosting to complex, high-availability upstream load balancing and secure SSL termination—we have verified the gateway's readiness for enterprise deployments.
