Nginx UDP 代理

问题描述 投票:0回答:1

我的 Nginx 配置如下:

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

stream {

  log_format basic '$remote_addr [$time_local] '
                   '$protocol $status $bytes_sent $bytes_received '
                   '$session_time';

  server {
    listen 1194 udp reuseport;
    access_log /var/log/nginx/stream-access.log basic;
    proxy_pass vpn;
    proxy_bind $remote_addr transparent;
    proxy_responses 0;
    proxy_timeout 1s;
  }
  server {
    listen 1195 udp;
    return "data";
  }
  upstream vpn {
    server 127.0.0.1:1195;
  }
}

我可以在端口 1195 上发送和接收数据,如下所示:

$ echo -n "hello" | nc -4u -w1 127.0.0.1 1195
data

但是如果我尝试使用代理并发送到端口 1194,我不会收到任何数据。

$ echo -n "hello" | nc -4u -w1 127.0.0.1 1194

有人知道为什么吗?

这也是日志的样子:

127.0.0.1 [26/Apr/2024:16:38:52 +0000] UDP 200 0 5 0.000
nginx udp
1个回答
0
投票

我确实想我已经明白了。指令

proxy_responses 0;
不期望或返回任何答案,所以我删除了它并且它按预期工作。

我试图通过 Nginx 隧道传输我的 Wireguard (DNS) VPN,但无法让它按预期工作,所以我放弃了。

© www.soinside.com 2019 - 2024. All rights reserved.