原文链接:https://blog.csdn.net/Activity_Time/article/details/95767390

1. stream模块安装

nginx默认安装的时候无法加载流stream模块,需要在启动参数里加上–with-stream。

解决方法:

重新对源文件进行编译、安装,通过添加–with-stream参数指定安装stream模块。

nginx安装教程

[root@localhost nginx-1.12.2]# ./configure --with-stream
[root@localhost nginx-1.12.2]# make & make install

configure命令设定安装参数

# 常用模块配置
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--with-stream \
--with-http_ssl_module

2.配置文件 nginx.conf

stream模块位于与http模块相同的层次

示例:

stream {
upstream backend {
server 202.118.163.18:3306;
} upstream landm {
server 202.118.163.18:8092;
} upstream nginxCon {
server 202.118.166.247:22;
} upstream stu.neau.actim.top {
server 202.118.163.18:80;
server 202.118.167.86:9004;
server 202.118.167.86:9003;
server 202.118.167.86:9002;
server 202.118.167.86:9001;
} server {
listen 8088;
proxy_connect_timeout 8s;
proxy_timeout 24h; #¿¿¿¿
proxy_pass backend;
} server {
listen 8082;
proxy_connect_timeout 8s;
proxy_timeout 24h; #¿¿¿¿
proxy_pass landm;
} server {
listen 8686;
proxy_connect_timeout 8s;
proxy_timeout 24h; #¿¿¿¿
proxy_pass nginxCon;
} server {
listen 8093;
proxy_connect_timeout 8s;
proxy_timeout 24h; #¿¿¿¿
proxy_pass stu.neau.actim.top;
}
}

3. 代理mysql、文件下载等tcp连接

stream在使用上与http相近,只需配置upstream然后再配置server即可,参考上面的配置,

代理mysql只需用反向代理服务器的一个端口去代理数据库服务器(集群)的端口即可,文件下载亦然


参考文章:

Nginx1.14.2新增tcp/udp代理stream(详细)

nginx代理tcp协议连接mysql

ssl模块安装(https)

Nginx反向代理+负载均衡简单实现(https方式)

https://blog.csdn.net/Activity_Time/article/details/95770900

nginx -stream(tcp连接)反向代理配置 实现代理mysql以及文件上传的更多相关文章

  1. [转]ExtJs入门之filefield:文件上传的配置+结合Ajax完美实现文件上传的asp.net示例

    原文地址:http://www.stepday.com/topic/?459 作文一个ExtJs的入门汉子,学习起来的确是比较费劲的事情,不过如今在这样一个网络资源如此丰富的时代,依然不是那么难了的. ...

  2. 配置php.ini实现PHP文件上传功能

    本文介绍了如何配置php.ini实现PHP文件上传功能.其中涉及到php.ini配置文件中的upload_tmp_dir.upload_max_filesize.post_max_size等选项,这些 ...

  3. 移动商城第四篇【Controller配置、添加品牌之文件上传和数据校验】

    Controller层配置 编写SpringMVC的配置文件 springmvc.xml <?xml version="1.0" encoding="UTF-8&q ...

  4. 配置openssh实现sftp远程文件上传

    客服端:winscp等ftp/sftp客户端 服务器:阿里云默认使用的openssh 需求:可以sftp远程传输文件到服务器固定文件夹下,不可远程ssh登录 步骤: 1. 建立系统用户ftpuser及 ...

  5. PHP 合理配置实现文件上传及保存文件到数据库

    合理配置 php.ini 如何配置php.ini实现PHP文件上传功能.其中涉及到php.ini配置文件中的upload_tmp_dir.upload_max_filesize.post_max_si ...

  6. nginx基于TCP的反向代理

    一.4层的负载均衡 Nginx Plus的商业授权版开始具有TCP负载均衡的功能.从Nginx 1.7.7版本开始加入的,现在变成了一个商业收费版本,想要试用,需要在官网申请.也就是说,Nginx除了 ...

  7. 影响 POST 请求文件上传失败的几个环节的配置(php + nginx)

    写在前面 最近写一个 php 接口,接受上传的文件,发现文件只要超过 5m 以上就会无响应失败,最后发现是 shadowsocks 的 timeout 设置问题(我全程开了全局的 VPN),但一开始并 ...

  8. tomcat相关配置技巧梳理 (修改站点目录、多项目部署、限制ip访问、大文件上传超时等)

    tomcat常用架构:1)nginx+tomcat:即前端放一台nginx,然后通过nginx反向代理到tomcat端口(可参考:分享一例测试环境下nginx+tomcat的视频业务部署记录)2)to ...

  9. Nginx集群之WCF大文件上传及下载(支持6G传输)

    目录 1       大概思路... 1 2       Nginx集群之WCF大文件上传及下载... 1 3       BasicHttpBinding相关配置解析... 2 4       编写 ...

随机推荐

  1. mybatis Invalid bound statement (not found)错误解决办法

    由于新版的IntelliJ IDEA不再编译source folder下的xml文件,而我们平时使用mybatis时,习惯于将*Mapper.xml文件放在与dao层.service层平级的src目录 ...

  2. 安装第三方包&查看python版本/第三方包版本

    安装第三方包时,经常需要查看python版本,以及是否安装第三方包及版本,每次都要百度下指令. 故小编整理了下安装/卸载第三方包,查看python/第三包的指令,具体如下: 一.python安装/卸载 ...

  3. 【读书笔记】:MIT线性代数(2):Vector Spaces and Subspaces

    Vector Space: R1, R2, R3,R4 , .... Each space Rn consists of a whole collection of vectors. R5 conta ...

  4. selenium,webdriver模仿浏览器访问百度 基础2

    学python理念  :  代码要多敲 一定要多敲 哪怕很基础  注释要清晰 由于基础1有一些注释写的很详细, 在这里有些注释没有写的很详细 可以配合基础1一起学习哦 from selenium im ...

  5. Cocos2d 之FlyBird开发---GamePlay类

    |   版权声明:本文为博主原创文章,未经博主允许不得转载. 这个是游戏的核心部分:(FlyBird游戏重中之重) 创建一个物理世界(世界设置重力加速度) 在物理世界中添加一个动态的刚体(小鸟) 在物 ...

  6. [Java] 缓存池

    new Integer(123) 与 Integer.valueOf(123) 的区别在于: new Integer(123) 每次都会新建一个对象: Integer.valueOf(123) 会使用 ...

  7. 【转】modulenotfounderror: no module named 'matplotlib._path'问题的解决

    今天在装matplotlib包的时候遇到这样的问题,在网上找了很长时间没有类似很好的解决方法,最后自己 研究找到了解决的方法. 之前在pycharm里面已经装了matplotlib包,之后觉着下载包挺 ...

  8. 42.Flatten Binary Tree to Linked List

    Level:   Medium 题目描述: Given a binary tree, flatten it to a linked list in-place. For example, given ...

  9. ps学习记录

    基本快捷键: ctrl + 放大 ctrl - 缩小 ctrl 空格键 放大工具 ctrl 0 适合屏幕大小 ctrl 1 显示实际大小 ctrl n 新建画布 ctrl v 移动工具 按住alt键 ...

  10. size - 列出段节大小和总共大小

    总览 (SYNOPSIS) size [-A|-B|--format=compatibility] [--help] [-d|-o|-x|--radix=number] [--target=bfdna ...