# Endpoint Agent and Proxy Issues

**URL:** https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977
**Category:** Endpoint Security
**Created:** [April 27, 2023, 3:24pm UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977 "2023-04-27T15:24:51Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jad3675](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jad3675/32/120338_2.png) [@jad3675](https://discuss.elastic.co/u/jad3675)
#### Post date: [April 27, 2023, 3:24pm UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977/1 "2023-04-27T15:24:51Z")

</div>

Windows Server 2019  
Elastic 8.6

Our environment has some devices that can only communicate with our Elastic cluster via a proxy. The elastic agent is setup with the environment registry keys (HKLM\SYSTEM\CurrentControlSet\Services\Elastic Agent\Environment) for http\_proxy and https\_proxy. The elastic agent respects and uses these environment variables.

When the server is added to an agent policy that has Endpoint security, the endpoint agent is deployed as expected. However, it is unable to communicate with our cluster because the install is not copying/using the environment variables from the elastic agent registry key.

Should be an easy enough fix - just add the appropriate registry keys to (HKLM\SYSTEM\CurrentControlSet\Services\ElasticEndpoint) and restart the server (since the endpoint service can't be restarted).

After the restart, this error is in the logs - '[elastic\_agent.endoint\_security] [info] Connecting to server localhost:6789 via HTTP proxy ipv4:(ipaddress of proxy)'.  
So the agent is using (and reading ) the proxy config from the registry, it just needs to exclude 'localhost' from being proxied. 'no\_proxy=localhost,127.0.0.1' is added to the Environment registry key and the server is restarted.

After the restart, this is in the logs: '[elastic\_agent.endoint\_security][debug] not using proxy for host in no\_proxy list 'dns:///localhost:6789'. So the agent is reading the 'no\_proxy' variable and applying it properly.

But....the elastic endpoint agent is not using the proxy config to communicate with fleet or our cluster. The agent logs are littered with communication issues between the endpoint agent, fleet and our cluster. The logs also contain '[elastic\_agent.endpoint\_security][info] ProxyConfig.cpp Proxy URL:'

Additionally, Process Explorer shows the endpoint-agent is NOT using the proxy, it's showing direct attempted connections to fleet.

Adding http\_proxy, https\_proxy and no\_proxy environmental variables to the system variables and restarting the server did not fix the issue for the endpoint service.

From an admin powershell prompt, running 'endpoint-agent.exe test output' - produces output that shows the proper proxy url and show connectivity to the cluster. If the https\_proxy, http\_proxy environmental variables are removed, the test output fails since it is attempting a direct connection.  
It appears that the executable is respecting the environmental variables and using them. It appears to be an issue with the elasticendpoint service not reading and using the environment variables - unless I am doing something wrong.

Any help would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![gabriel.landau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel.landau/32/73401_2.png) [@gabriel.landau](https://discuss.elastic.co/u/gabriel.landau)
#### Post date: [April 27, 2023, 4:20pm UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977/2 "2023-04-27T16:20:54Z")

</div>

Hi @jad3675,

You're correct that Endpoint doesn't support those registry keys. Endpoint protects its service key from modification/tampering, so even an administrator should not be able to set those registry keys.

```auto
PS C:\Windows\System32> $environment = [string[]]@(
>> "HTTPS_PROXY=https://proxy-hostname:proxy-port",
>> "HTTP_PROXY=http://proxy-hostname:proxy-port"
>> )
>>
>> Set-ItemProperty "HKLM:SYSTEM\CurrentControlSet\Services\ElasticEndpoint" -Name Environment -Value $environment
>>
Set-ItemProperty : Requested registry access is not allowed.
At line:6 char:1
+ Set-ItemProperty "HKLM:SYSTEM\CurrentControlSet\Services\ElasticEndpo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : PermissionDenied: (HKEY_LOCAL_MACH...ElasticEndpoint:String) [Set-ItemProperty], SecurityException
    + FullyQualifiedErrorId : System.Security.SecurityException,Microsoft.PowerShell.Commands.SetItemPropertyCommand

PS C:\Windows\System32> reg.exe add HKLM\SYSTEM\CurrentControlSet\Services\ElasticEndpoint /v Anything /t REG_SZ /d "testing"
ERROR: Access is denied.

```

Endpoint uses the same proxy configuration sent to Agent by Kibana, Starting with 8.7.0, you can set this directly in Kibana following the example [here](https://github.com/elastic/kibana/issues/140533#issuecomment-1451666108). I summarized the process here:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/0/a0ccca60684f2ae638f6423e021f9520d964569b.png)

I hope this helps.

Regards,  
Gabriel

---

<div class="post-metadata">

### Author: ![jad3675](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jad3675/32/120338_2.png) [@jad3675](https://discuss.elastic.co/u/jad3675)
#### Post date: [April 27, 2023, 5:04pm UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977/3 "2023-04-27T17:04:36Z")

</div>

Thanks for the quick reply....but it doesn't appear that endpoint supports the environmental variables either as a service? It respects it as a standalone run of the executable.

I was setting the keys in a hacky way - importing the key before I installed the endpoint agent. The installer doesn't clear it out before it install the endpoint-agent.

What is odd, as I pointed out, is that it appears to partially respect the http\_proxy variable. The agent couldn't connect to localhost:6789 until I explicitly put in a no\_proxy variable in the key.

Unfortunately, only part of our environment needs to use a proxy. We'd have to implement a separate output for these-proxied hosts then, correct?

How does the address the inability of the endpoint agent to download the artifacts (endpoint-exceptionlist-windows-v1, for example) from our single fleet server using a proxy? Would we need to deploy a second fleet server just for the proxied hosts and configure it to use the proxy?

Thanks again!  
John

---

<div class="post-metadata">

### Author: ![cmacknz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cmacknz/32/103773_2.png) [@cmacknz](https://discuss.elastic.co/u/cmacknz)
#### Post date: [April 28, 2023, 6:58pm UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977/4 "2023-04-28T18:58:22Z")

</div>

What specific 8.6 version are you using? In 8.6.2 and 8.7.0 there is a bug in the Elastic Agent where we receive an empty proxy URL from Fleet, and this takes precedence over any proxy you have configured locally. This was an unfortunate side effect of allowing the proxy URL to be configured form the UI. See [A Fleet proxy configured with the --proxy-url option when enrolling is not passed to endpoint security · Issue #2304 · elastic/elastic-agent · GitHub](https://github.com/elastic/elastic-agent/issues/2304#issuecomment-1497944166)

In 8.7.0 the Fleet Proxy URL can be configured from the Fleet UI as described above, setting the proxy to use there before enrolling the agent is one work around if you are affected by this bug.

Another option is to wait for 8.7.1 which will include the fix for this problem. We don't post the release dates publicly but it won't be a long wait.

---

<div class="post-metadata">

### Author: ![jad3675](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jad3675/32/120338_2.png) [@jad3675](https://discuss.elastic.co/u/jad3675)
#### Post date: [April 29, 2023, 10:34pm UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977/5 "2023-04-29T22:34:40Z")

</div>

We're at 8.6.2 - and that's good know with 8.7.1. So if I understand correctly - if I pass the --proxy-url during agent enrollment, that will get passed on to both the elastic and endpoint agent? If so, that's great.

Thanks again! I appreciate the help with this issue.

John

---

<div class="post-metadata">

### Author: ![cmacknz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cmacknz/32/103773_2.png) [@cmacknz](https://discuss.elastic.co/u/cmacknz)
#### Post date: [May 1, 2023, 1:46pm UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977/6 "2023-05-01T13:46:38Z")

</div>

Yes, the value of `--proxy-url` set on the command line will be stored and passed to both the Elastic Agent and Endpoint Security agent (with the exception of the bug I mentioned in 8.6.2 and 8.7.0).

---

<div class="post-metadata">

### Author: ![jad3675](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jad3675/32/120338_2.png) [@jad3675](https://discuss.elastic.co/u/jad3675)
#### Post date: [May 4, 2023, 11:52am UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977/7 "2023-05-04T11:52:56Z")

</div>

Craig -  
Thanks again - I upgraded our lab instance to 8.7.1 and verified that the --proxy-url flag is respected with the Elastic and Endpoint agent.

John

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 1, 2023, 11:53am UTC](https://discuss.elastic.co/t/endpoint-agent-and-proxy-issues/330977/8 "2023-06-01T11:53:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
