nginx负载 发向代理配置文件参考
来自server+iis linux可做参考 :
#user nobody;
worker_processes 8; #worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; worker_rlimit_nofile 102400;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
use epoll;
worker_connections 102400;
} http {
include mime.types;
default_type application/octet-stream;
#proxy_cache_path d:\imgdata\cache levels=1:2 keys_zone=imgcache:100m inactive=1d max_size=10g;
#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;
client_header_buffer_size 8k;
client_max_body_size 24m; gzip on; upstream www.yunxindai.com{ #server ip1:8080 weight=1 max_fails=2 fail_timeout=30s;
server ip2:80 weight=3 max_fails=2 fail_timeout=30s;
#server ip3:80 weight=3 max_fails=2 fail_timeout=30s;
server ip4:80 weight=3 max_fails=2 fail_timeout=30s;
server ip5:80 backup;
#server ip6:80 weight=3 max_fails=2 fail_timeout=30s;
ip_hash;
} #domain tiaozhuan
server {
listen 80;
server_name www.xx.net;
server_name www.xx.cn;
server_name xx.com;
#server_name www.xx.com.cn;
rewrite
^/(.*) http://www.yunxindai.com/$1 permanent;
} server {
listen 80;
server_name ip1;
server_name www.xx.com;
#server_name www.xx.cn;
server_name www.xx.com.cn;
#server_name www.xx.net; #charset koi8-r; #access_log logs/host.access.log main; location / {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_pass http://www.yunxindai.com;
#proxy_redirect default;
proxy_redirect off;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header remote-host $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 404 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;
# }
#} }
本人配置如下:
user nginx;
worker_processes 8;
worker_rlimit_nofile 51200; error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid; events {
use epoll;
worker_connections 51200;
} http {
include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on;
#tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; #设定负载均衡的服务器列表
upstream myServer {
#weigth参数表示权值,权值越高被分配到的几率越大
#本机上的apache开8080端口
server ip1:8080 weight=4 max_fails=2 fail_timeout=25s;
server ip2:80 weight=6 max_fails=2 fail_timeout=25s;
ip_hash;
} server {
listen 80;
server_name 域名; #可加多个域名
server_name ip1;
location / {
proxy_pass http://myServer;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr; #应用服务器上显示正式客户端ip }
}
}
nginx负载 发向代理配置文件参考的更多相关文章
- nginx负载均衡(反向代理)
6,安装nginx 6.1 依赖库安装 要安装在root根目录里,不要装在虚拟环境里面 yum install gcc-c++ pcre pcre-devel zlib zlib-devel ope ...
- 架构之Nginx(负载均衡/反向代理)
Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器 ,也是一个 IMAP/POP3/SMTP 代理 服务器 . Nginx 是由 Igor Sys ...
- nginx 负载均衡 反向代理
nginx 通过方向代理实现负载均衡,负载均衡是大流量网站要做的措施,单从字面上的意思来理解为N台服务器平均分担负载,不会因为某一台服务器负载高宕机而影响用户访问网站,负载均衡至少需要三台服务器, 既 ...
- Nginx负载均衡反向代理 后端Nginx获取客户端真实IP
Nginx 反向代理后,后端Nginx服务器无法正常获取客户端的真实IP nginx通过http_realip_module模块来实现的这需要重新编译,如果提前编译好了就无需重新编译了1,重新编译ng ...
- keepalived + nginx(负载均衡反向代理HTTP,https) + tomcat(HTTP,https)
基本架构: nginx(192.168.116.198) client --->keepalived(116.200) ------> tomcat (192.16 ...
- Nginx负载均衡反向代理
http{ upstream test.com { server 118.118.66.88:8080; } server { listen 80; server_name www.test.com; ...
- 解析nginx负载均衡
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://baidutech.blog.51cto.com/4114344/1033718 ...
- nginx负载均衡集群(二)
nginx负载均衡配置实战 一.配置基于域名虚拟主机的web节点 web02和web01做同样的操作,nginx配置文件如下: [root@web01 conf]# cat nginx.conf wo ...
- SqlServer 更改复制代理配置文件参数及两种冲突策略设置
原文:SqlServer 更改复制代理配置文件参数及两种冲突策略设置 由于经常需要同步测试并更改代理配置文件属性,所以总结成脚本,方便测试. 可更新订阅的冲突策略有两种情况:一是在发布中冲突,即订阅数 ...
随机推荐
- CSS Select 标签取选中文本值
$("#userDep").find("option:selected").text()
- ASP.net WebAPI 上传图片
[HttpPost] public Task<Hashtable> ImgUpload() { // 检查是否是 multipart/form-data if (!Request.Cont ...
- Delphi的MDI编程中遇到的一个奇怪问题(值得研究的一个问题)
近日在用delphi写一个多文档应用程序,除了一个主界面是自动生成的,其他功能页面全部都是通过Application.CreateForm()动态生成的,也就是说在ProjectManager中点击程 ...
- Windows平台下C++插件系统实现的几个关键技术问题及其解决思路
根据我的实践,在Windows平台下设计并实现一个C++插件系统,需要解决几个关键技术问题.下面我谈谈需要解决的几个关键技术问题以及我想到的简单的解决思路.由于我主要专注于Windows平台C++程序 ...
- 如何提取出ppt中的文字?
最近在看一位老师的教学视频,视频里大部分的知识都记录在ppt里,于是很想将ppt中的文字提取出来,如果我一页一页地粘贴复制的话,效率低到吓人,因为一章的ppt有130多页,于是在网上搜索了一下方法,与 ...
- BCS--使用SharePoint Designer创建外部内容类型
使用SharePoint Designer创建外部列表(也可以在浏览器中创建列表) http://www.cnblogs.com/haogj/archive/2011/05/01/2033845.ht ...
- Orchard站点性能优化-预热
Orchard CMS 包含一个 Warmup Module 模块,当我们的站点在共享主机上的时候,它可以显著的帮助我们快速响应用户访问请求.当你开启这个模块以后,你设置的URL的里面的内容会缓存起来 ...
- MVC中AuthorizeAttribute用法并实现权限控制
1.创建一个类(用来检查用户是否登录和用户权限)代码如下: public class AuthorizeFilterAttribute: AuthorizeAttribute { //Autho ...
- [Swust OJ 1023]--Escape(带点其他状态的BFS)
解题思路:http://acm.swust.edu.cn/problem/1023/ Time limit(ms): 5000 Memory limit(kb): 65535 Descript ...
- [置顶] 关于CSDN2013博客之星的一些看法
最近一个周,最火的话题当然要数CSDN2013博客之星拉票了. 实话实说,从12月14日开始,我连续5天拉票. 通过QQ群.QQ好友.CSDN文章.给CSDN粉丝发私信等多种方式拉票,真是累死我了. ...