|
| 1 | +--- |
| 2 | +title: Prepare - Set up an explicit forward proxy |
| 3 | +toc: true |
| 4 | +weight: 250 |
| 5 | +nd-docs: DOCS-000 |
| 6 | +--- |
| 7 | + |
| 8 | +NGINX Agent can be configured to connect to NGINX One using an explicit forward |
| 9 | +proxy. This is useful in environments where direct internet access is restricted or monitored. |
| 10 | + |
| 11 | +## Before you start |
| 12 | + |
| 13 | +Ensure you have the following: |
| 14 | + |
| 15 | +- An explicit forward proxy server installed and configured in your network. |
| 16 | +- [NGINX Agent is installed]({{< ref "nginx-one/agent/install-upgrade/" >}}) |
| 17 | +- Access to the [NGINX One console]({{< ref "/nginx-one/getting-started.md#before-you-begin" >}}). |
| 18 | + |
| 19 | + |
| 20 | +## NGINX Agent configuration for proxy usage |
| 21 | + |
| 22 | +1. Open a secure connection to your instance using SSH and log in. |
| 23 | +1. Open the NGINX Agent configuration file (/etc/nginx-agent/nginx-agent.conf) with a text editor. To edit this file you need superuser privileges. |
| 24 | +1. Add or modify the `proxy` section to include the proxy URL and timeout settings: |
| 25 | + |
| 26 | + ```conf |
| 27 | + server: |
| 28 | + host: agent.connect.nginx.com |
| 29 | + port: 443 |
| 30 | + proxy: |
| 31 | + url: "http://proxy.example.com:3128" |
| 32 | + ``` |
| 33 | + |
| 34 | +1. Restart NGINX Agent to apply the changes: |
| 35 | + |
| 36 | + ```sh |
| 37 | + sudo systemctl restart nginx-agent |
| 38 | + ``` |
| 39 | + |
| 40 | +### In a containerized environment |
| 41 | + |
| 42 | +To configure NGINX Agent in a containerized environment: |
| 43 | + |
| 44 | +1. Run the NGINX Agent container with the environment variables set as follows: |
| 45 | + |
| 46 | + ```sh |
| 47 | + sudo docker run \ |
| 48 | + --add-host "myproxy.example.com:host-gateway" \ |
| 49 | + --env=NGINX_AGENT_COMMAND_SERVER_PORT=443 \ |
| 50 | + --env=NGINX_AGENT_COMMAND_SERVER_HOST=agent.connect.nginx.com \ |
| 51 | + --env=NGINX_AGENT_COMMAND_AUTH_TOKEN="<your-data-plane-key-here>" \ |
| 52 | + --env=NGINX_AGENT_COMMAND_TLS_SKIP_VERIFY=false \ |
| 53 | + --env=NGINX_AGENT_COMMAND_SERVER_PROXY_URL=http://myproxy.example.com:3128 \ |
| 54 | + --restart=always \ |
| 55 | + --runtime=runc \ |
| 56 | + -d private-registry.nginx.com/nginx-plus/agentv3:latest |
| 57 | + ``` |
| 58 | + |
| 59 | + |
| 60 | +## NGINX Agent proxy authentication |
| 61 | + |
| 62 | +If your forward proxy requires authentication, you can specify the username and password in the `proxy` section of the `agent.conf` file: |
| 63 | + |
| 64 | +1. Open a secure connection to your instance using SSH and log in. |
| 65 | +1. Add or modify the `proxy` section of the NGINX Agent configuration file (/etc/nginx-agent/nginx-agent.conf) to include the authentication details: |
| 66 | + |
| 67 | + ```conf |
| 68 | + proxy: |
| 69 | + url: "http://proxy.example.com:3128" |
| 70 | + auth_method: "basic" |
| 71 | + username: "user" |
| 72 | + password: "pass" |
| 73 | + ``` |
| 74 | + |
| 75 | +1. Restart NGINX Agent to apply the changes: |
| 76 | + |
| 77 | + ```sh |
| 78 | + sudo systemctl restart nginx-agent |
| 79 | + ``` |
| 80 | + |
| 81 | +### In a containerized environment |
| 82 | + |
| 83 | +To set proxy authentication in a containerized environment: |
| 84 | + |
| 85 | +1. Run the NGINX Agent container with the environment variables set as follows: |
| 86 | + |
| 87 | + |
| 88 | + ```sh |
| 89 | + sudo docker run \ |
| 90 | + --add-host "myproxy.example.com:host-gateway" \ |
| 91 | + --env=NGINX_AGENT_COMMAND_SERVER_PORT=443 \ |
| 92 | + --env=NGINX_AGENT_COMMAND_SERVER_HOST=agent.connect.nginx.com \ |
| 93 | + --env=NGINX_AGENT_COMMAND_AUTH_TOKEN="<your-data-plane-key-here>" \ |
| 94 | + --env=NGINX_AGENT_COMMAND_TLS_SKIP_VERIFY=false \ |
| 95 | + --env NGINX_AGENT_COMMAND_SERVER_PROXY_URL=http://proxy.example.com:3128 |
| 96 | + --env NGINX_AGENT_COMMAND_SERVER_PROXY_AUTH_METHOD=basic |
| 97 | + --env NGINX_AGENT_COMMAND_SERVER_PROXY_USERNAME="user" |
| 98 | + --env NGINX_AGENT_COMMAND_SERVER_PROXY_PASSWORD="pass" |
| 99 | + --restart=always \ |
| 100 | + --runtime=runc \ |
| 101 | + -d private-registry.nginx.com/nginx-plus/agentv3:latest |
| 102 | + ``` |
| 103 | + |
| 104 | +## Validate connectivity between the components |
| 105 | + |
| 106 | +To test the connectivity between NGINX Agent, your proxy, and NGINX One Console, you can use the `curl` command with the proxy settings. |
| 107 | + |
| 108 | +1. Open a secure connection to your instance using SSH and log in. |
| 109 | +1. Run the following `curl` command to test the connection: |
| 110 | + ```sh |
| 111 | + curl -x http://proxy.example.com:3128 -U your_user:your_password https://agent.connect.nginx.com/api/v1/agents |
| 112 | + ``` |
| 113 | + |
| 114 | + - Replace `proxy.example.com:3128` with your proxy address and port. |
| 115 | + - Replace `your_user` and `your_password` with the credentials you set up for proxy in the previous steps. |
| 116 | + |
| 117 | +To test the configuration from a containerized environment, run the following command from within the container: |
| 118 | + |
| 119 | + ```sh |
| 120 | + curl -x http://host.docker.internal:3128 -U your_user:your_password https://agent.connect.nginx.com/api/v1/agents |
| 121 | + ``` |
| 122 | + |
| 123 | + - Replace `your_user` and `your_password` with the credentials you set up for proxy in the previous steps. |
| 124 | + |
0 commit comments