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 更改复制代理配置文件参数及两种冲突策略设置 由于经常需要同步测试并更改代理配置文件属性,所以总结成脚本,方便测试. 可更新订阅的冲突策略有两种情况:一是在发布中冲突,即订阅数 ...
随机推荐
- hadoop配置及无法移动文件到hdfs故障解析
首先博主用的64位ubuntu,hadoop官方只提供32位版本,这样的话启动本地库无法兼容,需要自己编译为64位版本,或下载别人编译好的64位版本. 下载好需要在etc/hadoop目录下改动以下几 ...
- 别忘记给你博客的windows live writer配置 ping服务
写好一篇博客,想要实现秒收.就必须要为文章添加ping服务. 这里介绍一下给wlw添加ping服务的办法. 点击工具---选项--ping服务器. 在右侧栏中加入以下地址 http://rpc.pin ...
- java中文乱码问题
•ASCII ØASCII使用7个比特(bit)进行字符编码,最多可以表示的字符数量为27(128)个字符,这些字符包括了大小写英文字母.阿拉伯数字.标点符号.控制字符和其他符号.每个字符用一个字节表 ...
- WebAppScaner
https://www.ohloh.net/p/simple-scan/ https://code.google.com/p/skipfish/ http://code.google.com/p/wa ...
- Python正则表达式一: 基本使用方法
学习python的正则表达式,主要有两个方面学习: 第一,学习如何写正则表达式,主要是掌握其语法规范.正则表达式的语法规范是通用的,对各种开发语言都是一致的. 第二,学习如何使用正则表达式,也就是掌握 ...
- 使用Win32 API创建不规则形状&带透明色的窗口
前一阵突然想起了9月份电面某公司实习时的二面题,大概就是说怎么用Win32 API实现一个透明的窗口,估计当时我的脑残答案肯定让面试官哭笑不得吧.所以本人决定好好研究下这个问题.经过一下午的摸索,基本 ...
- 今天刚申请成为Uber司机 已经接了5单了....大家有什么想问的吗?
今天刚申请成为Uber司机 已经接了5单了....大家有什么想问的吗? 滴滴快车单单2.5倍,注册地址:http://www.udache.com/如何注册Uber司机(全国版最新最详细注册流程)/ ...
- Maven模块聚合与继承
聚合 假如有account-email和account-persist两个模块,我们想要一次构建这两个项目,这时须要用到聚合. 聚合模块 package值必须为pom 必须有元素modules mod ...
- 在js中获取query string 以及重写URL的函数
函数用途:如标题.1. 从URL中解析出參数,2.重写URL中的參数值 例如以下代码所看到的.包括了測试.能够直接copy到浏览器中,输入測试地址:localhost:xxx?a=1&b=2& ...
- Codeforces 18C C. Stripe
Codeforces 18C C. Stripe 链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/E 题 ...