Docs/linux基础/nginx/使用nginx代理socket.txt
2022-10-18 16:59:37 +08:00

21 lines
497 B
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

编译安装nginx时需要在编译参数中加上--with-stream
windows下的nginx直接配置nginx.conf即可
在nginx.conf的events的同级目录配置stream块如下示例
events {
worker_connections 1024;
}
stream {
upstream socket_server{
server 127.0.0.1:3802 weight=1;
server 127.0.0.1:3803 weight=1;
    }
    #监听socket端口
    server {
listen 3801;
proxy_pass socket_server;
proxy_connect_timeout 10s;
proxy_timeout 300s
    }
}