跳转到内容
Ask AI

Nginx Configuration

此内容尚不支持你的语言。

[Command]

show nginx status

[Purpose]

Display the enabled status of Nginx and the number of cores utilized by Nginx, where Master_count is always 1, indicating the number of master processes of Nginx; Worker_count represents the number of cores corresponding to the Nginx service, defaulting to 2 and adjustable via the command line using the cpu_core nginx_num command.

[View]

System view

[Use Cases]

sonic# show nginx status
Status: OK
Master_count: 1
Worker_count: 2

[Command]

show nginx config

[Purpose]

Display the global parameter configuration results of nginx and the loading status of configuration files, such as cert files and server files.

[View]

System view

[Use Cases]

sonic# show nginx config
worker_processes: 3
worker_connections: 1500
keepalive_timeout: 80
server nginx_1:
listen: 17.1.1.2:188 ssl
ssl_certificate: /etc/sonic/nginx/cert/asterfusion.crt
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
fe:35:86:b8:2a:f2:79:8a
Signature Algorithm: ecdsa-with-SHA256
Issuer: C = CN, ST = SUZHOU, O = Internet Widgits Pty Ltd, CN = SO\08\1B[CPHIE
Validity
Not Before: Mar 17 08:07:41 2026 GMT
Not After : Mar 17 08:07:41 2027 GMT
Subject: C = CN, ST = HARBIN, O = Internet Widgits Pty Ltd, CN = LC
Subject Public Key Info:
Public Key Algorithm: id-ecPublicKey
Public-Key: (256 bit)
pub:
04:41:c5:64:9f:a1:13:76:6e:ea:9f:ac:a7:6d:c5:
3b:9f:d5:7d:e0:7e:d2:9f:27:b1:03:73:89:6f:22:
1a:44:e9:0a:6f:27:73:99:80:f8:eb:80:5e:35:94:
90:92:cc:0f:70:3f:2f:40:59:57:8c:81:15:f9:25:
75:14:a4:46:ed
ASN1 OID: prime256v1
NIST CURVE: P-256
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Key Usage:
Digital Signature, Non Repudiation, Key Encipherment
Signature Algorithm: ecdsa-with-SHA256
Signature Value:
30:45:02:21:00:a4:ed:6b:20:c2:97:09:5a:83:34:7d:1d:e0:
f2:0c:ca:ae:12:27:d8:6b:91:3b:b7:18:da:e8:08:17:1c:8e:
7d:02:20:55:52:19:d5:e7:f0:30:ca:5e:b7:76:76:ff:52:9c:
9e:42:44:aa:51:98:9a:fe:a2:36:57:b3:bd:f3:c8:01:91
server nginx_2:
listen: 199 ssl

[Command]

cpu_core {nginx_numstring1**| vpp_numstring2}**

no cpu_core

[Purpose]

Configure the number of cores for both VPP and nginx. When not configured, the default number of cores for VPP is 6 and for nginx is 1. For the ET2500 model device, there are a total of 8 cores. VPP defaults to using the last 6 cores (corresponding to core numbers 2-7), while nginx defaults to using the first core (for core number 0). The recommended number of cores to configure is set to 3 for vpp_num and 3 for nginx.

[View]

System configuration view

[Notes]

Note that when the device model is ET2500, nginx_num+vpp_num≤8, Attention should be paid during configuration; And after configuring the nginx core number, nginx reload needs to be executed to take effect, while vpp core number needs to be configured and the device writes and saves the configuration before reloading can take effect.When executing no cpu_core, both parameters will return to their default values.

[Use Cases]

sonic(config)# cpu_core vpp_num 3 nginx_num 3

[Command]

nginx start

[Purpose]

Enable nginx service, default to off state; After enabling, the enable status can be viewed by showing nginx status.

[View]

System configuration view

[Use Cases]

sonic(config)# nginx start

[Command]

nginx stop

[Purpose]

Disable nginx service.

[View]

System configuration view

[Use Cases]

sonic(config)# nginx stop

[Command]

nginx reload

[Purpose]

Reloading configuration is used for situations where nginx uploads new configuration files, global parameters, core configurations, or deletes related configuration files through updates. In other words, when nginx’s configuration changes, it is necessary to perform nginx reload to make the configuration loading effective.

[View]

System configuration view

[Use Cases]

sonic(config)# nginx reload

[Command]

nginx keepalive_timeouttime

[Purpose]

Configure nginx to maintain a timeout for TCP connections. Specify the number of seconds Nginx should keep the connection open and wait for subsequent requests after completing a request with the client. After timeout, the connection will be closed to save resources. After configuration, execute nginx reload to successfully load it.

[Parameter]

ParameterDescription
timeTimeout parameter, configurable range from 0 to 65535

[View]

System configuration view

[Use Cases]

sonic(config)# nginx keepalive_timeout 80

[Command]

nginx worker_connectionsnum

[Purpose]

Configure the maximum number of connections that each Nginx worker process can open simultaneously; This value affects the concurrent processing capability of the server, and the total concurrent limit needs to be calculated in conjunction with workr_processes. After configuration, execute nginx reload to successfully load it.

[Parameter]

ParameterDescription
numThe maximum number of connections for nginx processes can be configured within the range of 1 to 65535

[View]

System configuration view

[Use Cases]

sonic(config)# nginx worker_connections 1500

[Command]

**nginx update {cert|server}**string

[Purpose]

Configure the server configuration file path/authentication key file path for nginx. Note that the string needs to be specified as the full path. After configuration, execute nginx reload to successfully load it. The loading result can be viewed through show nginx config.

[Parameter]

ParameterDescription
stringConfigure the path of the Cert file/server configuration file that needs to be loaded.

[View]

System configuration view

[Use Cases]

sonic(config)# nginx update cert /home/admin/asterfusion.crt
sonic(config)# nginx update cert /home/admin/asterfusion.key
sonic(config)# nginx update server /home/admin/nginx_test1.conf