3

关于 nginx 四层转发问题求助

 1 year ago
source link: https://www.v2ex.com/t/894715
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  Linux

关于 nginx 四层转发问题求助

  cndns · 4 小时 35 分钟前 · 555 次点击
各位 v 友们好,因为是 4 层的转发需求,我想实现的目标是转发机器能把客户连过的 IP 传递到后端 windows 服务器上
看了下 iptables , rinetd 都均不能实现这种目的然后网上搜了 nginx 好像可以转发把真实客户 IP 传过去后端机器

nginx/1.22.1
编译安装参数如下
./configure --with-stream --with-stream_realip_module
make && make install
nginx.conf 配置文件如下
worker_processes auto;
events {
worker_connections 1024;
}
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';

upstream backend {
server 192.168.100.10:3389 ; #后端 windows 服务器
}
server {
listen 13389;
proxy_connect_timeout 10s;
proxy_timeout 30s;
proxy_protocol on ; # on 不正常改为 off 就正常
proxy_pass backend;
}
}
proxy_protocol 改为 off 就正常但是开启就不正常端口是通的但是无法远程桌面一直在尝试连接弹不出输入账户密码那一步,但是如果改成 off 的话,windows 服务器看不到真实客户端 IP

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK