Hi all ,
I have tried to setup agents on environment without internet access which connect to manager through proxy but i am going through few issues
1. Agents registered through proxy shows proxy ip address as source ip
2. If i set below forward settings to enable agent source ip its not working
http {
real_ip_header X-Forwarded-For
;
set_real_ip_from nginx_ip;
}
Wazuh Manager :
#/var/ossec/bin/manage_agents -l
Available agents:
Ā Ā ID: 001, Name:
9a67a918182c.mylabserver.com, IP: 172.31.19.15
Ā Ā ID: 002, Name:
9a67a918183c.mylabserver.com, IP: 172.31.16.208
Ā Ā
ID: 008, Name: 9a67a918184c.mylabserver.com, IP: 172.31.19.252
Nginx conf: ( /etc/nginx/nginx.conf )
-----------------
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
Ā Ā worker_connections 1024;
}
http {
Ā Ā log_format Ā main Ā '$remote_addr - $remote_user [$time_local] "$request" '
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā '$status $body_bytes_sent "$http_referer" '
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā '"$http_user_agent" "$http_x_forwarded_for"';
Ā Ā access_log Ā /var/log/nginx/access.log Ā main;
Ā Ā
real_ip_header X-Forwarded-For;
Ā Ā set_real_ip_from 172.31.19.252;Ā Ā sendfile Ā Ā Ā Ā Ā Ā on;
Ā Ā tcp_nopush Ā Ā Ā Ā Ā on;
Ā Ā tcp_nodelay Ā Ā Ā Ā on;
Ā Ā keepalive_timeout Ā 65;
Ā Ā types_hash_max_size 4096;
Ā Ā include Ā Ā Ā Ā Ā Ā /etc/nginx/mime.types;
Ā Ā default_type Ā Ā Ā Ā application/octet-stream;
Ā Ā # Load modular configuration files from the /etc/nginx/conf.d directory.
Ā Ā # See
http://nginx.org/en/docs/ngx_core_module.html#includeĀ Ā # for more information.
Ā Ā include /etc/nginx/conf.d/*.conf;
Ā Ā server {
Ā Ā Ā Ā listen Ā Ā Ā 80;
Ā Ā Ā Ā listen Ā Ā Ā [::]:80;
Ā Ā Ā Ā server_name Ā _;
Ā Ā Ā Ā root Ā Ā Ā Ā /usr/share/nginx/html;
Ā Ā Ā Ā # Load configuration files for the default server block.
Ā Ā Ā Ā include /etc/nginx/default.d/*.conf;
Ā Ā Ā Ā error_page 404 /404.html;
Ā Ā Ā Ā location = /404.html {
Ā Ā Ā Ā }
Ā Ā Ā Ā error_page 500 502 503 504 /50x.html;
Ā Ā Ā Ā location = /50x.html {
Ā Ā Ā Ā }
Ā Ā }
}
stream {
Ā upstream master {
Ā Ā server
puppet.mylabserver.com:1515;
Ā }
Ā upstream mycluster {
Ā Ā server
puppet.mylabserver.com:1514;
Ā Ā }
Ā server {
Ā Ā listen
172.31.19.252:1515;
Ā Ā proxy_pass master;
Ā }
Ā server {
Ā Ā listen
172.31.19.252:1514;
Ā Ā proxy_pass mycluster;
Ā }
}
Wazuh Agent:
--------------------
IP:Ā 172.31.30.6
/var/ossec/etc/ossec.conf:
-------------------------------------
.
.
.
<ossec_config>
Ā <client>
Ā Ā <server>
Ā Ā Ā <address>172.31.19.252</address>
Ā Ā Ā <port>1514</port>
Ā Ā Ā <protocol>tcp</protocol>
Ā Ā </server>
Ā Ā <config-profile>rhel, rhel7, rhel7.9</config-profile>
Ā Ā <notify_time>10</notify_time>
Ā Ā <time-reconnect>60</time-reconnect>
Ā Ā <auto_restart>yes</auto_restart>
Ā Ā <crypto_method>aes</crypto_method>
Ā </client>
.
.
.
Issue:
Wazuh receives the request from agent via proxy where it authorizes and register agent with proxy ip instead agent source ip .
manager ossec.log:
2022/09/15 17:56:05 wazuh-remoted: WARNING: (1213): Message from '172.31.19.252' not allowed. Cannot find the ID of the agent. Source agent ID is unknown.
2022/09/15 17:56:15 wazuh-remoted: WARNING: (1213): Message from '172.31.19.252' not allowed. Cannot find the ID of the agent. Source agent ID is unknown.
2022/09/15 17:56:25 wazuh-remoted: WARNING: (1213): Message from '172.31.19.252' not allowed. Cannot find the ID of the agent. Source agent ID is unknown.
2022/09/15 17:56:35 wazuh-remoted: WARNING: (1213): Message from '172.31.19.252' not allowed. Cannot find the ID of the agent. Source agent ID is unknown.
2022/09/15 17:56:45 wazuh-remoted: WARNING: (1213): Message from '172.31.19.252' not allowed. Cannot find the ID of the agent. Source agent ID is unknown.
2022/09/15 17:56:46 wazuh-authd: INFO: New connection from 172.31.19.252
2022/09/15 17:56:46 wazuh-authd: INFO: Received request for a new agent (9a67a918184c.mylabserver.com) from: 172.31.19.252
2022/09/15 17:56:46 wazuh-authd: INFO: Agent key generated for '9a67a918184c.mylabserver.com' (requested by 172.31.19.252)
2022/09/15 17:56:51 wazuh-remoted: INFO: (1409): Authentication file changed. Updating.
2022/09/15 17:56:51 wazuh-remoted: INFO: (1410): Reading authentication keys file.
How can we make proxy to send agent source ip or either manager to recognize agent source ip instead proxy ?
Regards,
Nandha