回答
收藏
分享
举报
Nginx Stream反向代理如何实现调用https服务
提问于2021-05-06 09:49

浏览 4.4k

需求:客户端通过nginx stream代理调用服务端https接口请求

问题:1)nginx需要配置证书么?

        2)编译时除了--with-stream模块,还需要什么模块?

        3)curl测试stream反向代理地址端口时是使用http还是https?

已修改于2023-03-16 15:54



写下您的回答
发表回答
全部回答(1)

按点赞数排序

按时间排序

如果不做TLS卸载,就不需要配置证书

赞同

0

回复举报

回答于2021-05-06 10:14



回复陶辉
回复
孙颖回复了

收到,多谢陶辉老师。目前碰到一个问题,使用stream做反向代理测试curl测试提示如下信息:

 curl https://www.baidu.com:9993
curl: (35) Encountered end of file


配置信息如下:

stream {

map $ssl_preread_server_name $backend_pool {
www.so.com server_ng;
www.baidu.com server_estpay;
}

upstream server_ng{
server www.so.com:443;
}

upstream server_estpay{
server www.baidu.com:443;
}

server{
listen 9993;
ssl_preread on;
proxy_pass $backend_pool;
proxy_connect_timeout 15s;
proxy_timeout 15s;
proxy_next_upstream_timeout 15s;
}

}


ng本机hosts配置:

133.0.183.163 www.baidu.com


--麻烦问下这种是什么问题,谢谢!

0

回复举报

回答于2021-05-08 04:37



回复孙颖
回复
提问者
孙颖
这家伙很懒还未留下介绍~
0
文章
1
问答
0
粉丝
相关问答

没有,N+才有

点赞 0
浏览 4k

低版本,编译会打印md5和sha1。我测试1.10版本,是打印md5和sha1的,1.11以上不打印了,可以查看
https://github.com/nginx/nginx/tree/master源代码代码仓库auto/summary文件,里面有描述。下面为我本地Ubuntu18.04编译指令:
在代码根目录运行,./auto/configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_module --add-module=/home/lq/work/tongmingzhiyun/openresty/lua-nginx-module-0.10.21 --add-module=/home/lq/work/tongmingzhiyun/openresty/ngx_devel_kit-0.3.1
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library

nginx path prefix: "/opt/nginx"
nginx binary file: "/opt/nginx/sbin/nginx"
nginx modules path: "/opt/nginx/modules"
nginx configuration prefix: "/opt/nginx/conf"
nginx configuration file: "/opt/nginx/conf/nginx.conf"
nginx pid file: "/opt/nginx/logs/nginx.pid"
nginx error log file: "/opt/nginx/logs/error.log"
nginx http access log file: "/opt/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"

点赞 0
浏览 3.8k


location / {
proxy_pass http://inter-router;
proxy_set_header Host ***;
proxy_http_version 1.1;
}
location ^~ /websocket/ {
proxy_pass http://inter-router/websocket/;
proxy_set_header Host ***;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 600s;
}

不要把websocket 配置放到通配符里面,那样就全部都是了,只对websocket部分,这样用,示例如上

点赞 0
浏览 4.2k