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

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 横渡

[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)  评论()    收藏  举报