【问题标题】:Socket connection through nginx通过 nginx 的套接字连接
【发布时间】:2011-06-25 12:39:54
【问题描述】:

我有一个生产服务器,它有一个 nginx 服务器来处理与多个服务的连接。在其他只能通过生产服务器的 VPN 看到的机器上,我有一个开发服务器,用于测试一些网络应用程序。

我想从互联网访问为开发机器提供的服务,所以我需要将传入的流量转发到开发服务器

1.- 使用套接字连接到 a.domain.com(端口 7081)的客户端请求

2.- nginx 必须转发这个,我有下面的代码

注意:a.domain.com 在 10.8.0.1 有一个 VPN 接口

server {
    listen       7081;
    server_name  a.domain.com;
    location / {
        proxy_pass http://10.8.0.210:7081;
        proxy_set_header  X-Real-IP  $remote_addr;
    }
}

3.- 在开发服务器 (10.8.0.210) 中,我在端口 7081 中有一个服务列表。

来自客户端的套接字连接返回以下内容

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/0.6.35</center>
</body>
</html>

4.- a.domain.com 的 nginx 服务器记录了以下内容

XXX.XXX.XX.XX - - [11/Feb/2011:08:58:10 -0300] "-" 400 173 "-" "-"

任何想法

谢谢

【问题讨论】:

  • 您在“10.8.0.210”的日志中看到了什么?

标签: python sockets proxy nginx vpn


【解决方案1】:

Bad request -- 表示它不是 http 请求。
Nginx 只能代理 http/smtp/pop3/imap 协议。

如果你想代理其他任何东西,你必须在 iptables 中使用例如 DNAT

【讨论】:

    猜你喜欢
    • 2015-05-07
    • 1970-01-01
    • 1970-01-01
    • 2013-11-07
    • 2019-10-02
    • 1970-01-01
    • 1970-01-01
    • 2020-05-09
    • 2015-09-23
    相关资源
    最近更新 更多