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