惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LangChain Blog
WordPress大学
WordPress大学
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
MyScale Blog
MyScale Blog
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
P
Proofpoint News Feed
D
DataBreaches.Net

博客园 - 横渡

[Linux] - 修改ls/ll显示的时间格式 [MySql] - Windows MySql 8.x 手动zip包安装与外网访问登录权限设定 [Windows] - DNS防污染工具Pcap_DNSProxy [Linux] - 服务器/VPS一键检测带宽、CPU、内存、负载、IO读写 [Windows] - Windows/Office纯绿色一键激活工具及方法 [Linux] - 利用ping给端口加密,限制访问 [Linux] - Windows与Linux网络共享文件夹挂载方法 [Linux] - 网速测试命令 [Linux] - CentOS运行DotNet Web程序 [Linux] - SVN忽略文件夹更新的命令与方法 [Linux] - n2n内网穿透 [Linux] - [转]*** Python版一键安装脚本 - 横渡 [Andriod] - Andriod Studio + 逍遥模拟器 [Linux] - centos使用mount + nfs 远程共享存储 [Linux] - Docker pure-ftp使用 [Linux] - Docker移动数据到其它盘的办法 [Nginx] - PHP+FPM相关的配置 [Linux] - 定时任务crontab [Linux] - 攻击查看与IP查封 [Linux] - Docker制作nginx+php
[Nginx] - 负载均衡配置
横渡 · 2016-07-06 · via 博客园 - 横渡

nginx.conf文件内容:

user  www www;
worker_processes  2;

error_log  /usr/local/nginx/logs/serror.log crit;
pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process. 
worker_rlimit_nofile 65535;

events 
{
  use epoll;
  worker_connections 65535;
}


http {
	include       mime.types;
	default_type  application/octet-stream;

	#charset  gb2312;

	server_names_hash_bucket_size 128;
	client_header_buffer_size 32k;
	large_client_header_buffers 4 32k;
	client_max_body_size 8m;

	sendfile on;
	tcp_nopush     on;

	keepalive_timeout 60;

	tcp_nodelay on;

	fastcgi_connect_timeout 300;
	fastcgi_send_timeout 300;
	fastcgi_read_timeout 300;
	fastcgi_buffer_size 64k;
	fastcgi_buffers 4 64k;
	fastcgi_busy_buffers_size 128k;
	fastcgi_temp_file_write_size 128k;

	gzip on;
	gzip_min_length  1k;
	gzip_buffers     4 16k;
	gzip_http_version 1.0;
	gzip_comp_level 2;
	gzip_types       text/plain application/x-javascript text/css application/xml;
	gzip_vary on;
	#limit_zone  crawler  $binary_remote_addr  10m;
	log_format '$remote_addr - $remote_user [$time_local] "$request" '
	              '$status $body_bytes_sent "$http_referer" '
	              '"$http_user_agent" "$http_x_forwarded_for"';
	include /usr/local/nginx/conf/vhosts/*.conf;
}

在vhosts目录下的conf文件内容:

upstream slave {
	server xxx.xxx.xxx.xxx max_fails=3 fail_timeout=30s weight=5;
	server xxx.xxx.xxx.xxx max_fails=3 fail_timeout=30s weight=5;
}

server {
	listen	80;
	server_name  www.XXX.com;
	
	#if ($uri ~* "(/login$|/login.html$|/login/index.html$|/admin/.+|/signup$|/signup/.+$|/signup.html$)") {
	#	return	301	https://$server_name$request_uri;
	#}

	location / {
		client_max_body_size 200m;
		proxy_pass http://slave;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		client_body_buffer_size 128k;
		proxy_connect_timeout 600;
		proxy_read_timeout 600;
		proxy_send_timeout 600;
		proxy_buffer_size 64k;
		proxy_buffers 4 32k;
		proxy_busy_buffers_size 64k;
		proxy_temp_file_write_size 64k;
	}

	location = /50x.html {
		root   html;
	}
}

server{
	listen 443;
	ssl on;
	ssl_certificate /alidata/ssl/server.crt;
	ssl_certificate_key /alidata/ssl/server.key;
	server_name  www.XXX.com;
	
	#if ($uri !~* "(/login$|/login.html$|/login/index.html$|/static/.+|/common/api/.+|/admin/.+|/signup$|/signup/.+$|/signup.html$)") {
	#	return	301	http://$server_name$request_uri;
	#}

	location / {
		client_max_body_size 200m;
		proxy_pass http://slave;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		client_body_buffer_size 128k;
		proxy_connect_timeout 600;
		proxy_read_timeout 600;
		proxy_send_timeout 600;
		proxy_buffer_size 64k;
		proxy_buffers 4 32k;
		proxy_busy_buffers_size 64k;
		proxy_temp_file_write_size 64k;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_redirect off;
	}

	location = /50x.html {
		root   html;
	}
}

posted @ 2016-07-06 11:22  横渡  阅读(855)  评论()    收藏  举报