You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows虚拟机上NGINX正向代理AWS托管MSSQL(1433端口)配置异常排查求助

Troubleshooting Nginx TCP/UDP Proxy for AWS RDS MSSQL on Windows VM

Hey there! Let's walk through fixing your Nginx proxy issue step by step—since you're new to Nginx, we'll start with the basics and work our way up.

First, let's clear up a critical configuration mistake: the stream block cannot be nested inside the http block—it needs to sit at the same level as http (and events) in your nginx.conf. Your original configuration structure is actually correct here, but it sounds like you tried moving it into http at some point, which would definitely break things. Let's stick with the top-level stream block.

Now let's go through actionable checks to diagnose the problem:

  • Validate your Nginx configuration syntax
    Open a command prompt, navigate to your Nginx installation directory (e.g., C:\nginx), and run:

    nginx -t
    

    This will tell you if there are any syntax errors in your config. If it returns "test is successful", you can rule out syntax issues; if not, fix the reported errors and restart Nginx.

  • Verify Nginx is listening on the correct ports
    On your Windows VM, run these commands in Command Prompt to check if Nginx is actually listening on 1433 (TCP) and 1434 (UDP):

    netstat -ano | findstr ":1433"
    netstat -ano | findstr ":1434"
    

    Look for entries where the "State" is LISTENING, and note the PID. Then open Task Manager, go to the Details tab, and confirm that PID belongs to nginx.exe. If another process is using these ports, you'll need to stop that process or change the listen ports in your Nginx config.

  • Test if your Windows VM can reach the AWS RDS instance directly
    Before blaming Nginx, confirm the VM itself can connect to the RDS database:

    1. Try using SQL Server Management Studio on the VM to connect to database.test.us-west-2.rds.amazonaws.com:1433—if this fails, the problem isn't Nginx, it's network connectivity between the VM and RDS.
    2. Alternatively, run telnet database.test.us-west-2.rds.amazonaws.com 1433 (enable Telnet on Windows first if needed) or use Test-NetConnection database.test.us-west-2.rds.amazonaws.com -Port 1433 in PowerShell.
      If this connection fails, check:
    • Your VM's outbound firewall rules: ensure it allows traffic to ports 1433 (TCP) and 1434 (UDP)
    • AWS RDS security group: confirm it allows inbound traffic from your VM's public IP (or private IP, if using VPC peering) to ports 1433/1434
  • Add a resolver to handle dynamic DNS for RDS
    AWS RDS instances can sometimes change their IP addresses, and Nginx caches DNS resolutions by default. Adding a resolver to your stream block ensures Nginx can re-resolve the RDS domain name if needed. Update your stream config like this:

    stream {
        resolver 8.8.8.8; # Google public DNS, or use your preferred DNS server
        upstream dbtcp {
            server database.test.us-west-2.rds.amazonaws.com:1433;
        }
        upstream dbudp {
            server database.test.us-west-2.rds.amazonaws.com:1434;
        }
        server {
            listen 1433;
            proxy_pass dbtcp;
            proxy_connect_timeout 1s;
        }
        server {
            listen 1434 udp;
            proxy_pass dbudp;
            proxy_connect_timeout 1s;
        }
    }
    
  • Check Nginx error logs for clues
    Windows Nginx logs are usually located in C:\nginx\logs\error.log (adjust the path if you installed Nginx elsewhere). Open this file and look for errors like:

    • host not found in upstream: Indicates a DNS resolution issue for your RDS domain
    • connection refused: Means Nginx can't reach the RDS instance from the VM
    • address already in use: Confirms port conflict we checked earlier

After making any config changes, remember to restart Nginx with:

nginx -s reload

Once you've worked through these steps, test connecting from your local device again using your VM's public IP and port 1433.

内容的提问来源于stack exchange,提问作者Ashwani Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 20:47:40