Score:0

nginx mirror traffic configuration issues

au flag

I am trying to mirror the SNMP trap across multiple servers. It uses TCP/IP traffic. I am using nginx to complete this but i am getting the following error

vsrsadmin@TRAP02:~$ sudo nginx -t

nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:118

nginx: configuration file /etc/nginx/nginx.conf test failed
stream{
upstream dns_servers {
least_conn;
server 192.168.49.19:162 max_fails=1 fail_timeout=30s;
}

upstream mir_dns_servers {
least_conn;
server 192.168.49.15:162 max_fails=1 fail_timeout=30s;
}
#}

server {
listen 162;
# proxy_bind $remote_addr:$remote_port transparent;
# proxy_pass dns_servers;

location / {
mirror /mirror;
mirror_request_body on;
proxy_pass dns_servers;
}

location = /mirror {
mirror /mirror;
mirror_request_body on;
proxy_pass mir_dns_servers;
proxy_connect_timeout 200ms;
proxy_read_timeout 200ms;
Score:0
us flag

stream is meant for relaying raw TCP traffic.

ngx_http_mirror_module is meant for mirroring HTTP requests to a different destination.

Raw TCP traffic does not contain HTTP traffic, so therefore mirror module cannot be used with it.

I don't think nginx can be used for the mirror operation you are trying to perform. I don't know if there is any tool for your objective.

Rohan Raj avatar
au flag
Is there any other tool i can use to mirror the Traffice that is not HTTP?
Rohan Raj avatar
au flag
is there any way to mirror tcp traffic like snmp trap?
Score:0
br flag

The issue with the configuration file seems to be that the "location" directive is placed inside the "stream" context. The "location" directive is only applicable in the "http" context, so it cannot be used in the "stream" context.

But you can move the "location" directive inside an "http" block, and see what happens.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.