0

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;
vidarlo
  • 6,654
  • 2
  • 18
  • 31
Rohan Raj
  • 1
  • 1

2 Answers2

0

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.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
0

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.

Salim Aljayousi
  • 341
  • 1
  • 3