在金山逍遙網中,前端負載平衡伺服器採用的是Nginx,兩台Nginx伺服器為一組,承擔多種類型的負載平衡服務,兩台負載平衡伺服器均處於活動狀態,各自綁定一個公網虛擬IP,作為負載平衡伺服器,當其中一個發生故障時,另一台接管發生故障伺服器的虛擬IP。設定nginx.conf程式碼如下
程式碼:
user www www; work_processes 8; error_log /data1/logs/nginx_error.log crit; pid /usr/local/webserver/nginx/nginx.pid;#specifies the value for maximum file descriptors that can be opened by this process worker_rlimit_nofile 51200events { use epoll; worker_connections 51200; } http { include mine.types; default_type application/octet-strem; #charset utf-8 server_names_hash_bucket_size 128k; client_header_buffer_size 32k; large_client_header_buffers 432k; sendfile on; #tcp_nopush on; keepalive_timeout 30; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 464k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 416k; gzip_http_version 1.1 gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; limit_zone anti_attack $binary_remote_addr10m; #允许客户端请求的最大单文件字节数client_max_body_size 300m; #缓冲区代理缓冲用户端的最大字节数 可以理解为现存到本地再传给用户client_body_size 128k; #跟后端服务器连接的超时时间_发起握手等候响应超时时间proxy_connect_time 600; #连接成功后_等待后端服务器响应时间_其实已经进入后端的派对等候处理proxy_read_timeout 600; #后端回传时间_规定时间内传完所有数据proxy_send_timeout 600; #代理请求缓存区,保存用户的头信息以供Nginx进行规则处理proxy_buffer_size 16k; proxy_buffers 432k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k;#缓存proxy_temp_path /data2/proxy_temp_path; proxy_cache_path /data2/proxy_cache_path levels=1:2 keys_z>200m inactive=1d max_size=5; upstream myserver_pool{ server xx.xx.xx.1:80 weight=1 max_fails=2 fail_timeout=30s; server xx.xx.xx.2:80 weight=1 max_fails=2 fail_timeout=30s; server xx.xx.xx.3:80 weight=1 max_fails=2 fail_timeout=30s; } upstream php_server_pool{ server xx.xx.xx.4:80 weight=1 max_fails=2 fail_timeout=30s; server xx.xx.xx.5:80 weight=1 max_fails=2 fail_timeout=30s; server xx.xx.xx.6:80 weight=1 max_fails=2 fail_timeout=30s; server xx.xx.xx.7:80 weight=1 max_fails=2 fail_timeout=30s; server xx.xx.xx.8:80 weight=1 max_fails=2 fail_timeout=30s; } upstream bbs_server_pool{ ip=hash; server xx.xx.xx.9:80 max_fails=2 fail_timeout=30s; server xx.xx.xx.10:80 max_fails=2 fail_timeout=30s; server xx.xx.xx.11:80 max_fails=2 fail_timeout=30s; server xx.xx.xx.12:80 max_fails=2 fail_timeout=30s; } upstream cms_server_pool{ server xx.xx.xx.13:80 weight=1 max_fails=2 fail_timeout=30s; server xx.xx.xx.14:80 weight=1 max_fails=2 fail_timeout=30s; } upstream pic_server_pool{ server xx.xx.xx.15:80 weight=1 max_fails=2 fail_timeout=30s; server xx.xx.xx.16:80 weight=1 max_fails=2 fail_timeout=30s; } upstream xoyohimsg_server_pool{ server xx.xx.xx.17:3245; server xx.xx.xx.18:3245 down; }#xoyo.com域名调转到www.xoyo.com server { listen 80; server_name xiyo.com; rewrite ^/(.*) http:xoyo.com/ permanent; acces_log /data1/logs/xoyo.com_access.log; }#用户中心HTTP/SSL加密浏览server { listen 443; server_name my.xoyo.com ssl on; ssl_cretificate my.xoyo.com.crt; ssl_cretificate_key my.xoyo.com.key; location / { proxy_pass http://php_server_pool; proxy_set_header Host my.xoyo.com; proxy_set_header X-Forward-For $remote_addr; } access_log /data1/logs/my.xoyo.com_access.log; }#图片服务器,不同的路径访问后端不同的服务器server { listen 80; server_name pic.xoyo.com; location /cms/ { proxy_pass http://cms_server_pool; proxy_set_header Host pic.xoyo.com; proxy_set_header X-Forward-For $remote_addr; } access_log /data1/logs/pic.xoyo.com_access.log; }#音频电台文件下载,进行简单防盗链#limit_zone media %binary_remote_addr 10m;server { listen 80; server_name media.xoyo.com; location / { proxy_pass http://cms_server_pool; proxy_set_header Host $host; proxy_set_header X-Forward-For $remote_addr; valid_reference nine blocked www.xoyo.com *.xoyo.com www.kingsoft.com *.kingsoft.com www.kingsoft.cn *.kingsoft.cn;if ($invalid_referers){ rewrite ^/ http://www.xoyo.com; } } access_log /data1/logs/media.xoyo.com_access.log; }#“逍遥有聊”WebIM产品的负载均衡,反向代理两种HTTP服务器server { listen 80; server_name hi.xoyo.com;#反向代理一款定制开发的高性能消息队列HTTP服务器location /recmessage.xoyo { proxy_pass http://xoyohimsg_server_pool; proxy_set_header Host $host; } location / { proxy_pass http://php_server_pool; proxy_set_header Host $host; proxy_set_header X-Forward-For $remote_addr; } access_log /data1/logs/hi.xoyo.com_access.log; #论坛负载均衡并对图片、Flash、JavaScript、CSS、静态HTML进行Web缓存server { listen 80; server_name bbs.xoyo.com *.bbs.xoyo.com bbs.xoyo.kingsoft.com; location / { proxy_pass http://bbs_server_pool; proxy_set_header Host $host; proxy_set_header X-Forward-For $remote_addr; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html|shtml)$ { proxy_cache cache_one; proxy_cache_valid 20010m; proxy_cache_valid 3041m; proxy_cache_valid 301302 ih; proxy_cache_valid any 1m; proxy_cache_key $host$uri$is_args$args; proxy_set_header Host $host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://bbs_server_pool; } log_format bbs ' $remote_addr $host $remote_user [$time_local] "$request"''"$status" $body_bytes_sent "$http_referer"''"$http_user_agent" "$http_x_forwarded_for"'; access_log /data1/logs/bbs.xoyo.com_access.log bbs; }#论坛附件反向代理,限制下载速度为256k/秒server{ listen 80; server_name att03.bbs.xoyo.com att02.bbs.xoyo.com att01.bbs.xoyo.com; location /{#限制下载速度为256k/slimit_rate 256k; proxy_pass http://xx.xx.xx.19; proxy_set_header Host $host; proxy_set_header X-Forward-For $remote_addr; } access_log off; }#逍遥江湖SNS社区,管理后台定位到一台服务器上,并对图片,flash,javascript,CSS进行web缓存 server { listen 80; server_name hu.xoyo.com *.hu.xoyo.com; location / { proxy_pass http://php_server_pool; proxy_set_header Host $host; proxy_set_header X-Forward-For $remote_addr; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ { proxy_cache cache_one; proxy_cache_valid 20010m; proxy_cache_valid 3041m; proxy_cache_valid 301302 ih; proxy_cache_valid any 1m; proxy_cache_key $host$uri$is_args$args; proxy_set_header Host $host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://php_server_pool; } location ~ ^/admincp.php { proxy_set_header Host $host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://xx.xx.xx.4; } access_log /data1/logs/hu.xoyo.com_accsee.log; } }
版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。
以上介紹了N年前Nginx 負載平衡在金山逍遙網中的應用,包括了方面的內容,更多相關內容請關注PHP中文網(www.php.cn)!

本篇文章给大家带来了关于nginx的相关知识,其中主要介绍了nginx拦截爬虫相关的,感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。

高并发系统有三把利器:缓存、降级和限流;限流的目的是通过对并发访问/请求进行限速来保护系统,一旦达到限制速率则可以拒绝服务(定向到错误页)、排队等待(秒杀)、降级(返回兜底数据或默认数据);高并发系统常见的限流有:限制总并发数(数据库连接池)、限制瞬时并发数(如nginx的limit_conn模块,用来限制瞬时并发连接数)、限制时间窗口内的平均速率(nginx的limit_req模块,用来限制每秒的平均速率);另外还可以根据网络连接数、网络流量、cpu或内存负载等来限流。1.限流算法最简单粗暴的

实验环境前端nginx:ip192.168.6.242,对后端的wordpress网站做反向代理实现复杂均衡后端nginx:ip192.168.6.36,192.168.6.205都部署wordpress,并使用相同的数据库1、在后端的两个wordpress上配置rsync+inotify,两服务器都开启rsync服务,并且通过inotify分别向对方同步数据下面配置192.168.6.205这台服务器vim/etc/rsyncd.confuid=nginxgid=nginxport=873ho

nginx php403错误的解决办法:1、修改文件权限或开启selinux;2、修改php-fpm.conf,加入需要的文件扩展名;3、修改php.ini内容为“cgi.fix_pathinfo = 0”;4、重启php-fpm即可。

跨域是开发中经常会遇到的一个场景,也是面试中经常会讨论的一个问题。掌握常见的跨域解决方案及其背后的原理,不仅可以提高我们的开发效率,还能在面试中表现的更加

nginx部署react刷新404的解决办法:1、修改Nginx配置为“server {listen 80;server_name https://www.xxx.com;location / {root xxx;index index.html index.htm;...}”;2、刷新路由,按当前路径去nginx加载页面即可。

nginx禁止访问php的方法:1、配置nginx,禁止解析指定目录下的指定程序;2、将“location ~^/images/.*\.(php|php5|sh|pl|py)${deny all...}”语句放置在server标签内即可。

linux版本:64位centos6.4nginx版本:nginx1.8.0php版本:php5.5.28&php5.4.44注意假如php5.5是主版本已经安装在/usr/local/php目录下,那么再安装其他版本的php再指定不同安装目录即可。安装php#wgethttp://cn2.php.net/get/php-5.4.44.tar.gz/from/this/mirror#tarzxvfphp-5.4.44.tar.gz#cdphp-5.4.44#./configure--pr


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Dreamweaver CS6
視覺化網頁開發工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),