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 更改复制代理配置文件参数及两种冲突策略设置 由于经常需要同步测试并更改代理配置文件属性,所以总结成脚本,方便测试. 可更新订阅的冲突策略有两种情况:一是在发布中冲突,即订阅数 ...
随机推荐
- Linux必学的60个命令【转载】
Linux提供了大量的命令,利用它可以有效地完成大量的工 作,如磁盘操作.文件存 [转载地址]http://blog.chinaunix.net/uid-16728139-id-3154272.ht ...
- Failure [INSTALL_FAILED_OLDER_SDK]
在AndroidManifest.xml 中把 <uses-sdk android:minSdkVersion="21" />的版本调节的低一点
- spring boot 下 500 404 错误页面处理
spring boot 作为微服务的便捷框架,在错误页面处理上也有一些新的处理,不同于之前的spring mvc 500的页面处理是比较简单的,用java config或者xml的形式,定义如下的be ...
- Hope
透过希望的窗棂,在阴霾的罅隙里也可以寻找阳光,看到未来的春暖花开. ——forever97
- HDOJ 1423 Greatest Common Increasing Subsequence(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1423 思路分析:[问题定义]给定两个序列A[0, 1,..., m]和B[0, 1, ..., n], ...
- Flex 动画效果
1.使用自带效果 在Flex里面不像在Flash里面随意制作动画了,Flex更趋向于应用程序,而不是动画制作了,所以没有了时间轴的概念.在Flex中使用动画效果,可以用Flex自带的Effect,或者 ...
- QT renered html for js
voidMainWindow::on_pushButton_clicked() { QStringurl="http://www.baidu.com"; url="htt ...
- 【已解决】谁动了我的CurrentPrincipal?求助我在给Artech的wcf petshop增加授权机制的时候遇到的问题。
这个问题已解决,是绑定设置的问题,主要还是因为我自己没有深入理解WCF绑定的安全机制.在这篇博客里面我来说说怎么解决的. 下载了Artech的wcf petshop源码(博文链接)并调试运行成功后,打 ...
- SQL Server 性能优化
今天有位网友找我给他原有的系统数据库优化下查询速度,个人总结了几点对sqlserver的优化 1.Sql查询语句的优化,如:能使用外连接查询出来的尽量别用内连接...,这些个就不废话,如果我使用这个给 ...
- CSS3学习笔记之linear-gradient
我觉得CSS3很不错,自己也稍微看过,并且尝试过一些属性.对我自己而言,我没有勇气说我学过CSS3,我觉得任何自己看来很小的事情,也只是站在自己的角度来评判.就算的是"简单的"HT ...