【问题标题】:nginx proxypass TCP 389nginx proxypass TCP 389
【发布时间】:2021-05-31 20:30:06
【问题描述】:
我们有一个“OpenLDAP”服务器,端口 389 当前处于活动状态,使用 nginx,我们希望将此 TCP 端口 389 代理传递到基于 TCP 的入口。任何人都可以为此分享 nginx.conf 的详细信息。
到目前为止,还剩下不完整的,如下所示,
upstream rtmp_servers {
server acme.example.com:389;
}
server {
listen 389;
server_name localhost:389;
proxy_pass rtmp_servers;
proxy_protocol on;
}
遇到错误,感谢任何建议
2021/03/02 09:45:39 [emerg] 1#1:不允许使用“proxy_pass”指令
在这里 /etc/nginx/conf.d/nginx-auth-tunnel.conf:9 nginx: [emerg]
此处不允许使用“proxy_pass”指令
/etc/nginx/conf.d/nginx-auth-tunnel.conf:9
【问题讨论】:
标签:
nginx
nginx-reverse-proxy
【解决方案1】:
- 您的配置应位于
stream 块中
- 你不需要
server_name localhost:389;
- 您正在包含来自
/etc/nginx/conf.d 文件夹的配置,该文件夹包含在主 nginx.conf 文件中的 http 块中。 流块应与 http 块处于同一级别。检查/etc/nginx/nginx.conf 中的include,也许您必须为流部分添加一个
这是一个示例 nginx.conf,
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf; #This include is your problem
}
stream {
upstream rtmp_servers {
server acme.example.com:389;
}
server {
listen 389;
proxy_pass rtmp_servers;
proxy_protocol on;
}
}