Nagstamon icon indicating copy to clipboard operation
Nagstamon copied to clipboard

"Use Proxy" option not working

Open robertkrenn opened this issue 1 year ago • 21 comments

We have several firewallrules in our company so that most internal an external URIs are only accessible via proxy. Direct connections are blocked. While accessing icingaweb in the browser works fine via proxy, nagstamon doesn't even use the proxy configuration. We tried the "Use Proxy from OS" option, also as manually configuring the proxy settings. Doesn't matter, nagstamon still tries to connect directly. Is there a known bug for this behaviour? Or am I missing something?

robertkrenn avatar Jul 18 '22 09:07 robertkrenn

Which monitoring server do you use?

HenriWahl avatar Aug 07 '22 07:08 HenriWahl

Icinga2 Am 7. Aug. 2022, 09:07 +0200 schrieb Henri Wahl @.***>:

Which monitoring server do you use? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

robertkrenn avatar Aug 07 '22 07:08 robertkrenn

Icinga2

I assume with IcingaWeb2 monitor in Nagstamon?

HenriWahl avatar Aug 14 '22 18:08 HenriWahl

Could you please provide some debugging output by enable debugging in the settings dialog of Nagstamon?

HenriWahl avatar Aug 14 '22 18:08 HenriWahl

Sorry for the late reply. It's kind of difficult to get the users to talk who are affected by this. The it center core team has direct http access to icingaweb2, but all others have to go over the proxy, especially when coming in over vpn. It doesn't matter if they configure to use os proxy settings or setting the proxy manually, nagstamon dismisses these settings and try directly. We were able to see this on our firewall, where the direct connections are blocked and the nagstamon runs into timeout. I already installed Version 3.10, but the issue is still the same. I'll try further to get some logs. but maybe you have already an clue where to search for the issue.

robertkrenn avatar Jan 11 '23 15:01 robertkrenn

Here is the Debugoutput of Nagstamon

DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DD74CA0> for state "OK" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DD74E50> for state "INFORMATION" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DD74820> for state "UNKNOWN" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC691B0> for state "WARNING" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC692D0> for state "AVERAGE" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC69360> for state "HIGH" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC693F0> for state "CRITICAL" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC69480> for state "DISASTER" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC69510> for state "UNREACHABLE" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC695A0> for state "DOWN" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC69630> for state "ERROR" DEBUG: 2023-01-12 07:05:18.301168 Saving configuration to file c:\users\stopsaka.nagstamon\nagstamon.conf DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DD74DC0> for state "OK" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DD756C0> for state "INFORMATION" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DD74CA0> for state "UNKNOWN" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DD74E50> for state "WARNING" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DD74820> for state "AVERAGE" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC691B0> for state "HIGH" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC692D0> for state "CRITICAL" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC69360> for state "DISASTER" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC693F0> for state "UNREACHABLE" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC69480> for state "DOWN" DEBUG: SystemTrayIcon created icon <Nagstamon.QUI.QIconWithFilename object at 0x000002540DC69510> for state "ERROR" DEBUG: 2023-01-12 07:05:18.309861 Icinga2 Refreshing all hosts and services DEBUG: 2023-01-12 07:05:19.093771 Icinga2 FetchURL: https://icinga2.augsburg.de/icingaweb2/authentication/login CGI Data: None ERROR: 2023-01-12 07:05:29.106417 Icinga2 Traceback (most recent call last): File "urllib3\connection.py", line 174, in _new_conn File "urllib3\util\connection.py", line 95, in create_connection File "urllib3\util\connection.py", line 85, in create_connection TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "urllib3\connectionpool.py", line 703, in urlopen File "urllib3\connectionpool.py", line 386, in _make_request File "urllib3\connectionpool.py", line 1042, in _validate_conn File "urllib3\connection.py", line 358, in connect File "urllib3\connection.py", line 179, in _new_conn urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x000002540DD89C60>, 'Connection to icinga2.augsburg.de timed out. (connect timeout=10)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "requests\adapters.py", line 489, in send File "urllib3\connectionpool.py", line 787, in urlopen File "urllib3\util\retry.py", line 592, in increment urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='icinga2.augsburg.de', port=443): Max retries exceeded with url: /icingaweb2/authentication/login (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000002540DD89C60>, 'Connection to icinga2.augsburg.de timed out. (connect timeout=10)'))_

robertkrenn avatar Jan 12 '23 07:01 robertkrenn

I think we just found the problem. When defining the proxy manually http://:, how it is configured in Windows and all other Linux systems, it also didn't work, Only when adding an "/" at the end. We found it by installing a complete fresh install of nagstamon without any preconfiguration where an example config "http://proxyserver:port/" is in place, so we just changed the middle part and left the "/" in place. Et voila, it works

As Windows itself delivers/saves the proxy config without the ending "/", but nagstamon needs the "/", the option "Use proxy from OS" will not work. Perhaps you shouldn't expect the "/" as mandatory for proxy configuration to work.

robertkrenn avatar Jan 12 '23 14:01 robertkrenn

Hi @robertkrenn, thanks for investigating.

When set to use OS proxy the property trust_env of the uses requests library is set: https://requests.readthedocs.io/en/latest/api/#requests.Session.trust_env. This means Nagstamon does not know about the proxy because the underlaying library cares about. The configuration is evaluated in https://github.com/HenriWahl/Nagstamon/blob/master/Nagstamon/Servers/Generic.py#L334-L337.

Looks like this should be extended not to let requests do the work, at least at Windows. Then there must be found out how to get the proxy settings from OS. Finally I found the method https://docs.python.org/3/library/urllib.request.html#urllib.request.getproxies being used, which on Windows looks into the registry to find information about the used proxy. This one again uses request.getproxies() from standard library urllib so I think one could use this call to and add the needed / .

HenriWahl avatar Jan 18 '23 06:01 HenriWahl

Tried to apply in https://github.com/HenriWahl/Nagstamon/tree/proxy-issue-825 - can you please check this from source in your environment?

HenriWahl avatar Jan 22 '23 17:01 HenriWahl

@robertkrenn did this finally work?

HenriWahl avatar Mar 18 '23 12:03 HenriWahl

We finally go with the manual proxy settings an the final „/“. This works for us Am 18. März 2023, 13:33 +0100 schrieb Henri Wahl @.***>:

@robertkrenn did this finally work? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

robertkrenn avatar Mar 18 '23 13:03 robertkrenn

@robertkrenn does it work without "/" now too?

HenriWahl avatar Mar 18 '23 15:03 HenriWahl

I have the same problem with proxy: (Caused by ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 407 Proxy Authentication Required') I use the " Use proxy from OS" or username, password and proxy address option in Nagstamon 3.12.0 but i have the same issue

Stonerpr91 avatar Oct 04 '23 09:10 Stonerpr91

The message

407 Proxy Authentication Required

indicates some server response - any idea what causes it?

HenriWahl avatar Oct 10 '23 17:10 HenriWahl

The message

407 Proxy Authentication Required

indicates some server response - any idea what causes it?

I think it's an authentication error with the proxy. In my office we use a proxy with WEB authentication. I enter the credentials in the Nagstamon proxy configuration but the message always appears.

Stonerpr91 avatar Oct 10 '23 18:10 Stonerpr91

What credentials are needed for the proxy? Might they be wrong?

HenriWahl avatar Oct 10 '23 19:10 HenriWahl

What credentials are needed for the proxy? Might they be wrong?

each user has their own credentials to access the proxy and have free access to the internet. these credentials are entered in the settings of each program to use the internet. The credentials are correct and have been checked multiple times.

Stonerpr91 avatar Oct 11 '23 07:10 Stonerpr91

@Stonerpr91 what monitoring server type do you use?

HenriWahl avatar Oct 11 '23 16:10 HenriWahl

@Stonerpr91 what monitoring server type do you use?

Nagios monitoring type

Stonerpr91 avatar Oct 11 '23 16:10 Stonerpr91

@Stonerpr91 as a workaround: did you try @robertkrenn 's trick with the trailing /?

HenriWahl avatar Oct 30 '23 12:10 HenriWahl

@Stonerpr91 please try latest testing release 2.13-20231030.

HenriWahl avatar Oct 30 '23 14:10 HenriWahl