|
| 1 | +--- |
| 2 | +nd-product: MSC |
| 3 | +nd-files: |
| 4 | +- content/nginx-one-console/getting-started.md |
| 5 | +--- |
| 6 | + |
| 7 | +If SSL is enabled on the NGINX Plus API with self-signed certificates like this example: |
| 8 | + |
| 9 | +```nginx |
| 10 | +# This block enables the NGINX Plus API and dashboard with SSL |
| 11 | +# For configuration and security recommendations, see: |
| 12 | +# https://docs.nginx.com/nginx/admin-guide/monitoring/live-activity-monitoring/#configuring-the-api |
| 13 | +server { |
| 14 | + # Change the listen port if 9000 conflicts |
| 15 | + # (8080 is the conventional API port) |
| 16 | + listen 9000 ssl; |
| 17 | + ssl_certificate /etc/nginx/certs/nginx-selfsigned.crt; |
| 18 | + ssl_certificate_key /etc/nginx/certs/nginx-selfsigned.key; |
| 19 | +
|
| 20 | + location /api/ { |
| 21 | + # To restrict write methods (POST, PATCH, DELETE), uncomment: |
| 22 | + # limit_except GET { |
| 23 | + # auth_basic "NGINX Plus API"; |
| 24 | + # auth_basic_user_file /path/to/passwd/file; |
| 25 | + # } |
| 26 | +
|
| 27 | + # Enable API in write mode |
| 28 | + api write=on; |
| 29 | +
|
| 30 | + # To restrict access by network, uncomment the following lines and set your network: |
| 31 | + # allow 192.0.2.0/24; # replace with your network |
| 32 | + # allow 127.0.0.1/32; # allow local NGINX Agent to call the NGINX Plus API to retrieve metrics |
| 33 | + # deny all; |
| 34 | + } |
| 35 | +
|
| 36 | + # Serve the built-in dashboard at /dashboard.html |
| 37 | + location = /dashboard.html { |
| 38 | + root /usr/share/nginx/html; |
| 39 | + } |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +NGINX Agent configuration needs to be update with the following to enable the NGINX Agent to be able to call the NGINX Plus API. |
| 44 | +``` |
| 45 | +data_plane_config: |
| 46 | + nginx: |
| 47 | + api_tls: |
| 48 | + ca: "/etc/nginx/certs/nginx-selfsigned.crt" |
| 49 | +``` |
| 50 | + |
| 51 | +Here is an example of how to generate self-signed certificates |
| 52 | +``` |
| 53 | +openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/certs/nginx-selfsigned.key -out /etc/nginx/certs/nginx-selfsigned.crt -subj "/CN=localhost" -addext "subjectAltName=IP:127.0.0.1" |
| 54 | +``` |
0 commit comments