下载地址:

http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/nginx-1.15.9-1.el7_4.ngx.x86_64.rpm

安装:

rpm -ivh nginx-1.15.9-1.el7_4.ngx.x86_64.rpm

配置:

vi /etc/nginx/nginx.conf

  1. #user nobody;
  2. worker_processes 1;
  3.  
  4. #error_log logs/error.log;
  5. #error_log logs/error.log notice;
  6. #error_log logs/error.log info;
  7.  
  8. #pid logs/nginx.pid;
  9.  
  10. events {
  11. worker_connections 1024;
  12. }
  13.  
  14. http {
  15. include mime.types;
  16. default_type application/octet-stream;
  17.  
  18. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  19. # '$status $body_bytes_sent "$http_referer" '
  20. # '"$http_user_agent" "$http_x_forwarded_for"';
  21.  
  22. #access_log logs/access.log main;
  23.  
  24. sendfile on;
  25. #tcp_nopush on;
  26.  
  27. #keepalive_timeout 0;
  28. keepalive_timeout 65;
  29.  
  30. #gzip on;
  31.  
  32. server {
  33. listen 80;
  34. server_name localhost;
  35.  
  36. #charset koi8-r;
  37.  
  38. #access_log logs/host.access.log main;
  39.  
  40. location / {
  41. root html;
  42. index index.html index.htm;
  43. }
  44.  
  45. #error_page 404 /404.html;
  46.  
  47. # redirect server error pages to the static page /50x.html
  48. #
  49. error_page 500 502 503 504 /50x.html;
  50. location = /50x.html {
  51. root html;
  52. }
  53.  
  54. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  55. #
  56. #location ~ \.php$ {
  57. # proxy_pass http://127.0.0.1;
  58. #}
  59.  
  60. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  61. #
  62. #location ~ \.php$ {
  63. # root html;
  64. # fastcgi_pass 127.0.0.1:9000;
  65. # fastcgi_index index.php;
  66. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  67. # include fastcgi_params;
  68. #}
  69.  
  70. # deny access to .htaccess files, if Apache's document root
  71. # concurs with nginx's one
  72. #
  73. #location ~ /\.ht {
  74. # deny all;
  75. #}
  76. }
  77.  
  78. # another virtual host using mix of IP-, name-, and port-based configuration
  79. #
  80. #server {
  81. # listen 8000;
  82. # listen somename:8080;
  83. # server_name somename alias another.alias;
  84.  
  85. # location / {
  86. # root html;
  87. # index index.html index.htm;
  88. # }
  89. #}
  90.  
  91. # HTTPS server
  92. #
  93. #server {
  94. # listen 443 ssl;
  95. # server_name localhost;
  96.  
  97. # ssl_certificate cert.pem;
  98. # ssl_certificate_key cert.key;
  99.  
  100. # ssl_session_cache shared:SSL:1m;
  101. # ssl_session_timeout 5m;
  102.  
  103. # ssl_ciphers HIGH:!aNULL:!MD5;
  104. # ssl_prefer_server_ciphers on;
  105.  
  106. # location / {
  107. # root html;
  108. # index index.html index.htm;
  109. # }
  110. #}
  111.  
  112. }
  113.  
  114. stream {
  115. upstream cloudsocket {
  116. hash $remote_addr consistent;
  117. # $binary_remote_addr;
  118. server 192.168.182.155:3306 weight=5 max_fails=3 fail_timeout=30s;
  119. }
  120. server {
  121. listen 3306;#数据库服务器监听端口
  122. proxy_connect_timeout 10s;
  123. proxy_timeout 300s;#设置客户端和代理服务之间的超时时间,如果5分钟内没操作将自动断开。
  124. proxy_pass cloudsocket;
  125. }
  126. }

nginx反向代理mysql及负载的更多相关文章

  1. Nginx反向代理实现Tomcat负载均衡

    这篇短文主要介绍Tomcat的集群和用Nginx反向代理实现Tomcat负载均衡. 1.首先需要对一些知识点进行扫盲(对自己进行扫盲,囧): 集群(Cluster) 简单来说就是用N台服务器构成一个松 ...

  2. Nginx反向代理 实现Web负载均衡

    实现负载均衡的方式有很多种,DNS.反向代理.LVS负载均衡器(软件实现).F5(负载均衡器,硬件,非常昂贵)这里我们只提到基于DNS,以及反向代理的方式来实现负载均衡Web服务       DNS服 ...

  3. nginx反向代理实现均衡负载及调度方法

    http upstream配置参数: ngx_http_upstream_module模块将多个服务器定义成服务器组,而由proxy_pass, fastcgi_pass等指令进行引用 upstrea ...

  4. nginx 反向代理 和lvs负载均衡

    nginx反向代理:用户请求nginx代理服务器然后代理服务器将用户请求转为服务器再由nginx代理服务器将服务器的响应反应给用户. lvs负载均衡:用户请求nginx代理服务器然后代理服务器将用户请 ...

  5. Nginx反向代理及简单负载均衡配置

    nginx配置文件主要分为六个区域:main section.events section.http section.sever section.location section.upstream s ...

  6. iperf测试流量转发(nginx反向代理tcp/udp)

    一.准备工作 服务器1:192.168.33.102     搭建nginx服务,作为反向代理的中转站 服务器2:192.168.33.103    nginx要反向代理的服务器 服务器3:192.1 ...

  7. 十.nginx反向代理负载均衡服务实践部署

    期中集群架构-第十章-nginx反向代理负载均衡章节章节====================================================================== 0 ...

  8. Linux 下 Nginx 反向代理 负载均衡配置

    转载请注明出处:http://blog.csdn.net/smartbetter/article/details/52036350 上一篇分享了 Nginx + JDK + Tomcat + MySQ ...

  9. Linux系统——Nginx反向代理与负载均衡

    集群集群是指一组(若干个)相互独立的计算机,利用高速通信网路组成的一个较大的计算机服务系统,每个集群节点(即集群中的每台计算机)都是运用各自服务的独立服务器.这些服务器之间可以彼此通信,协同向用户提供 ...

随机推荐

  1. selenium:chromedriver与chrome版本对应关系

    1.chromedriver下载地址:http://npm.taobao.org/mirrors/chromedriver 2.谷歌浏览器与chromedriver的版本对应关系,供参考: Chrom ...

  2. 2008nian元旦

    我要做---->> 控制财务状况---1记账 2 炒股或基金 3预算 锻炼---每次要达到锻炼的效果 学习计划-- 1报班架构 2 项目管理 3读书 爱好---做饭,收拾整理 职业规划. ...

  3. Django01-Django基础

    一.什么是web框架? 框架,即framework,特指为解决一个开放性问题而设计的具有一定约束性的支撑结构,使用框架可以帮你快速开发特定的系统.对于所有的Web应用,本质上其实就是一个socket服 ...

  4. .Net 中读写Oracle数据库常用两种方式

    .net中连接Oracle 的两种方式:OracleClient,OleDb转载 2015年04月24日 00:00:24 10820.Net 中读写Oracle数据库常用两种方式:OracleCli ...

  5. 微擎系统jssdk系统快速签名变量

    jssdkconfig = {php echo json_encode($_W['account']['jssdkconfig']);} || { jsApiList:[] };    jssdkco ...

  6. json11阅读

    概要:json11是一个基于c++11的json解析库,dropbox出品. 使用 直接举自带单元测试test.cpp中的例子: const string simple_test = R"( ...

  7. 阅读【现代网络技术 SDN/NFV/QOE 物联网和云计算】 第一章

    本人打算阅读这本书来了解物联网和云计算的基础架构和设计原理.特作笔记如下: 作者: William  Stallings 本书解决的主要问题: 由单一厂商例如IBM向企业或者个人提供IT产品和服务,包 ...

  8. eclipse装了springboot插件后yml文件没有自动提示问题

    选择打开方式:spring yaml

  9. 分布式Snowflake雪花算法

    前言 项目中主键ID生成方式比较多,但是哪种方式更能提高的我们的工作效率.项目质量.代码实用性以及健壮性呢,下面作了一下比较,目前雪花算法的优点还是很明显的. 优缺点比较 UUID(缺点:太长.没法排 ...

  10. 虚拟机下 centos7 无法连接网络

    [root@localhost ~]# cd /etc/sysconfig/network-scripts [root@localhost network-scripts]# ls ifcfg-ens ...