nginx反向代理mysql及负载
下载地址:
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
#user nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include 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 logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 80;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} } stream {
upstream cloudsocket {
hash $remote_addr consistent;
# $binary_remote_addr;
server 192.168.182.155:3306 weight=5 max_fails=3 fail_timeout=30s;
}
server {
listen 3306;#数据库服务器监听端口
proxy_connect_timeout 10s;
proxy_timeout 300s;#设置客户端和代理服务之间的超时时间,如果5分钟内没操作将自动断开。
proxy_pass cloudsocket;
}
}
nginx反向代理mysql及负载的更多相关文章
- Nginx反向代理实现Tomcat负载均衡
这篇短文主要介绍Tomcat的集群和用Nginx反向代理实现Tomcat负载均衡. 1.首先需要对一些知识点进行扫盲(对自己进行扫盲,囧): 集群(Cluster) 简单来说就是用N台服务器构成一个松 ...
- Nginx反向代理 实现Web负载均衡
实现负载均衡的方式有很多种,DNS.反向代理.LVS负载均衡器(软件实现).F5(负载均衡器,硬件,非常昂贵)这里我们只提到基于DNS,以及反向代理的方式来实现负载均衡Web服务 DNS服 ...
- nginx反向代理实现均衡负载及调度方法
http upstream配置参数: ngx_http_upstream_module模块将多个服务器定义成服务器组,而由proxy_pass, fastcgi_pass等指令进行引用 upstrea ...
- nginx 反向代理 和lvs负载均衡
nginx反向代理:用户请求nginx代理服务器然后代理服务器将用户请求转为服务器再由nginx代理服务器将服务器的响应反应给用户. lvs负载均衡:用户请求nginx代理服务器然后代理服务器将用户请 ...
- Nginx反向代理及简单负载均衡配置
nginx配置文件主要分为六个区域:main section.events section.http section.sever section.location section.upstream s ...
- iperf测试流量转发(nginx反向代理tcp/udp)
一.准备工作 服务器1:192.168.33.102 搭建nginx服务,作为反向代理的中转站 服务器2:192.168.33.103 nginx要反向代理的服务器 服务器3:192.1 ...
- 十.nginx反向代理负载均衡服务实践部署
期中集群架构-第十章-nginx反向代理负载均衡章节章节====================================================================== 0 ...
- Linux 下 Nginx 反向代理 负载均衡配置
转载请注明出处:http://blog.csdn.net/smartbetter/article/details/52036350 上一篇分享了 Nginx + JDK + Tomcat + MySQ ...
- Linux系统——Nginx反向代理与负载均衡
集群集群是指一组(若干个)相互独立的计算机,利用高速通信网路组成的一个较大的计算机服务系统,每个集群节点(即集群中的每台计算机)都是运用各自服务的独立服务器.这些服务器之间可以彼此通信,协同向用户提供 ...
随机推荐
- python:爬虫获取淘宝/天猫的商品信息
[需求]输入关键字,如书包,可以搜索出对应商品的信息,包括:商品标题.商品链接.价格范围:且最终的商品信息需要符合:包邮.价格差不会超过某数值 #coding=utf-8 ""&q ...
- java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager
一个比较老的web项目, IDEA 导入后不能用, 出现了各种问题, 但是, 别人用eclipse 导入就不会有问题, 我折腾了半天, 还是各种问题, 真是郁闷了. 哎, 承认很难配置吧, ...
- leetcode5
public class Solution { private int lo, maxLen; public String LongestPalindrome(String s) { int len ...
- HTML5-canvas1.0
HTML5 <canvas> 元素用于图形的绘制,通过脚本 (通常是JavaScript)来完成.<canvas> 标签只是图形容器,您必须使用脚本来绘制图形.你可以通过多种方 ...
- kubectl-常用命令
出处https://cloud.tencent.com/developer/article/1140076 kubectl apply -f kubernetes-dashboard.yaml -n ...
- Java6及以上版本对synchronized的优化
目录 1.概述 2.实现同步的基础 3.实现方式 4.Java对象头(存储锁类型) 5.优化后synchronized锁的分类 6.锁的升级(进化) 6-1.偏向锁 6-2.轻量级锁 6-3.锁的比较 ...
- tomcat双击startup.bat启动时闪退
tomcat之前用的好好地没有问题,今天重启一下就发现双击startup.bat一闪而过,接着就没有任何动静了,tomcat无法启动啦? 于是网上搜了一堆tomcat闪退的解决办法,其中有说是没有读取 ...
- C语言实现的反转字符串
这段代码大约是10年前写的了,一直收藏在自己的代码仓库里面,贴出来分享下. 网上也有很多类似的代码,学生们用的比较多,工作中用的很少,权做参考. char* ReverseString(char* s ...
- Linux下chkconfig命令介绍
一.引论 chkconfig命令检查.设置系统的各种服务.这是Red Hat公司遵循GPL规则所开发的程序,它可查询操作系统在每一个执行等级中会执行哪些系统服务, 其中包括各类常驻服务.谨记chkco ...
- php中使用com组件出现"拒绝访问"的处理
php中使用com组件出现"拒绝访问"的处理 2010年05月14日 12:28:00 阅读数:1529 代码如下, // 建立一个指向新COM组件的索引 $word = new ...