首页 > 解决方案 > 修改 nginx.conf 以侦听 UDP 端口并将收到的消息转发到另一个 IP 地址

问题描述

语境

我需要用可以托管静态 IPv4 地址并转发的 Azure 资源管理器 (ARM) 资源替换 Azure 经典云工作者角色(其工作是侦听专用固定 IP 地址,例如 99.99.99.99 udp 端口​​ 10000) UDP 流量。

解决方案

作为垫脚石的一种正在测试的解决方案是在 Azure Windows Server VM 上使用 NGINX,并将数据转发到另一个托管容器服务的 ARM 资源。

问题

NGINX 对我来说是全新的,我正在努力将 nginx.conf 配置为

我已经从另一篇堆栈文章中尝试过这个(下面是我的 nginx.conf 文件的副本,直到我实现了更改,即从“流”):


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
worker_connections  1024;
}

http {
include       mime.types;
default_type  application/octet-stream;

#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  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

stream {
server {
    listen 10100 udp;
    proxy_pass juniper_close_stream_backend;
}
upstream juniper_close_stream_backend {
    server 99.99.99.99:10000;
}
}

#error_page  404              /404.html;

修改此配置文件时,NGINX 服务将无法启动。搜索系统日志我找不到任何错误消息。显然配置更改的格式不正确。我可以恢复到默认文件并启动服务。

问题

如何将 nginx.config 修改为

  1. 监听 IPv4 地址
  2. 在 UDP 端口 10000
  3. 然后将收到的消息转发到另一个 IPv4 地址?

谢谢

标签: windowsazurenginxudpnginx-reverse-proxy

解决方案


推荐阅读