欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Nginx反向代理+DNS輪詢+IIS7.5 千萬PV 百萬IP 雙線 網(wǎng)站架構(gòu)案例

 更新時間:2012年11月10日 16:42:28   作者:  
某公司有一站點,一天IP 430W,PV 3100W,之前采用5臺 DELL R610 做NLB,系統(tǒng)2008 IIS7.5.每天高峰期時都不堪重負(fù).會出現(xiàn)以下情況
Nginx  ("engine x") 是一個高性能的 HTTP 和反向代理服務(wù)器,也是一個 IMAP/POP3/SMTP 代理服務(wù)器。 Nginx 是由 Igor Sysoev 為俄羅斯訪問量第二的 Rambler.ru 站點開發(fā)的,它已經(jīng)在該站點運行超過兩年半了。Igor 將源代碼以類BSD許可證的形式發(fā)布。

  Nginx 的中文維基:http://wiki.codemongers.com/NginxChs

  在高并發(fā)連接的情況下,Nginx是Apache服務(wù)器不錯的替代品。Nginx同時也可以作為7層負(fù)載均衡服務(wù)器來使用。根據(jù)我的測試結(jié)果,Nginx 0.5.31 + PHP 5.2.4 (FastCGI) 可以承受3萬以上的并發(fā)連接數(shù),相當(dāng)于同等環(huán)境下Apache的10倍。

  Nginx 超越 Apache 的高性能和穩(wěn)定性,使得國內(nèi)使用 Nginx 作為 Web 服務(wù)器的網(wǎng)站也越來越多,其中包括新浪博客、新浪播客、網(wǎng)易新聞、騰訊網(wǎng)、搜狐博客等門戶網(wǎng)站頻道,六間房、56.com等視頻分享網(wǎng)站,Discuz!官方論壇、水木社區(qū)等知名論壇,盛大在線、金山逍遙網(wǎng)等網(wǎng)絡(luò)游戲網(wǎng)站,豆瓣、人人網(wǎng)、YUPOO相冊、金山愛詞霸、迅雷在線等新興Web 2.0網(wǎng)站。

    在高并發(fā)連接的情況下,Nginx是Apache服務(wù)器不錯的替代品。Nginx同時也可以作為7層負(fù)載均衡服務(wù)器來使用。根據(jù)我的測試結(jié)果,Nginx 0.8.46 + PHP 5.2.14 (FastCGI) 可以承受3萬以上的并發(fā)連接數(shù),相當(dāng)于同等環(huán)境下Apache的10倍。

  根據(jù)我的經(jīng)驗,4GB內(nèi)存的服務(wù)器+Apache(prefork模式)一般只能處理3000個并發(fā)連接,因為它們將占用3GB以上的內(nèi)存,還得為系統(tǒng)預(yù)留1GB的內(nèi)存。我曾經(jīng)就有兩臺Apache服務(wù)器,因為在配置文件中設(shè)置的MaxClients為4000,當(dāng)Apache并發(fā)連接數(shù)達(dá)到3800時,導(dǎo)致服務(wù)器內(nèi)存和Swap空間用滿而崩潰。

  而這臺 Nginx 0.8.46 + PHP 5.2.14 (FastCGI) 服務(wù)器在3萬并發(fā)連接下,開啟的10個Nginx進(jìn)程消耗150M內(nèi)存(15M*10=150M),開啟的64個php-cgi進(jìn)程消耗1280M內(nèi)存(20M*64=1280M),加上系統(tǒng)自身消耗的內(nèi)存,總共消耗不到2GB內(nèi)存。如果服務(wù)器內(nèi)存較小,完全可以只開啟25個php-cgi進(jìn)程,這樣php-cgi消耗的總內(nèi)存數(shù)才500M。

  在3萬并發(fā)連接下,訪問Nginx 0.8.46 + PHP 5.2.14 (FastCGI) 服務(wù)器的PHP程序,仍然速度飛快。下圖為Nginx的狀態(tài)監(jiān)控頁面,顯示的活動連接數(shù)為28457(關(guān)于Nginx的監(jiān)控頁配置,會在本文接下來所給出的Nginx配置文件中寫明):

Highslide JS

Highslide JS



為什么Nginx的性能要比Apache高得多?這得益于Nginx使用了最新的epoll(Linux 2.6內(nèi)核)和kqueue(freebsd)網(wǎng)絡(luò)I/O模型,而Apache則使用的是傳統(tǒng)的select模型。目前Linux下能夠承受高并發(fā)訪問的Squid、Memcached都采用的是epoll網(wǎng)絡(luò)I/O模型。

  處理大量的連接的讀寫,Apache所采用的select網(wǎng)絡(luò)I/O模型非常低效。下面用一個比喻來解析Apache采用的select模型和Nginx采用的epoll模型進(jìn)行之間的區(qū)別:

  假設(shè)你在大學(xué)讀書,住的宿舍樓有很多間房間,你的朋友要來找你。select版宿管大媽就會帶著你的朋友挨個房間去找,直到找到你為止。而epoll版宿管大媽會先記下每位同學(xué)的房間號,你的朋友來時,只需告訴你的朋友你住在哪個房間即可,不用親自帶著你的朋友滿大樓找人。如果來了10000個人,都要找自己住這棟樓的同學(xué)時,select版和epoll版宿管大媽,誰的效率更高,不言自明。同理,在高并發(fā)服務(wù)器中,輪詢I/O是最耗時間的操作之一,select和epoll的性能誰的性能更高,同樣十分明了。

    某公司有一站點,一天IP 430W,PV 3100W,之前采用5臺 DELL R610 做NLB,系統(tǒng)2008 IIS7.5.每天高峰期時都不堪重負(fù).會出現(xiàn)以下情況
1:遠(yuǎn)程登陸巨慢無比
2:遠(yuǎn)程登陸系統(tǒng)后無法操作,表現(xiàn)為鼠標(biāo)移動緩慢,操作延時,系統(tǒng)呆滯.
3:CPU長期在80%以上,內(nèi)存消耗極高
4:....
    經(jīng)過部門討論后決定采用Nginx反向代理的架構(gòu)替代目前不堪重負(fù)的站點.拓?fù)鋱D如下

Highslide JS

硬件:
前端采用2臺DELL M420刀片,虛擬4臺Centos5.8跑Nginx反向代理.
后端依舊采用5臺服務(wù)器,不過從硬件上也升級到DELL M420 2008系統(tǒng) IIS7.5

網(wǎng)絡(luò)結(jié)構(gòu):
Nginx
電信 192.168.0.1 192.168.0.2
聯(lián)通 192.168.1.1 192.168.1.2

2008 IIS7.5
電信 192.168.0.10 192.168.0.11 192.168.0.13 192.168.0.14 192.168.0.15
聯(lián)通 192.168.1.10 192.168.1.11 192.168.1.13 192.168.1.14 192.168.1.15

域名xxx.com通過DNS輪詢到 Nginx前端,再根據(jù)你的配置甩向不同upstream

新架構(gòu)部署好后能明顯感覺整個站點打開都飛快,后端完全無壓力狀態(tài),這還并沒有開啟Nginx自帶的Cache.
現(xiàn)在這套架構(gòu)每天承載百萬IP 千萬PV的訪問量 如圖
AWStats 統(tǒng)計結(jié)果
Highslide JS

Nginx性能圖如下
Highslide JS

單臺Centos CPU圖
Highslide JS




安裝步驟:
一:
2臺宿主機(jī)虛擬成4臺這個步驟就略過,網(wǎng)上教程一大把.在這里我們每臺分配2個cpu共8個核心,內(nèi)存6G,硬盤100G.
系統(tǒng)要求:Linux 2.6+ 內(nèi)核,本文中的Linux操作系統(tǒng)為CentOS 5.8 64位)
系統(tǒng)為最精簡安裝文本界面,系統(tǒng)安裝好后配置系統(tǒng).

#修改系統(tǒng)DNS

rm -rf /etc/resolv.conf
touch /etc/resolv.conf
echo -ne "nameserver 114.114.114.114\nnameserver 114.114.115.115\nsearch localdomain" >>/etc/resolv.conf


#修改系統(tǒng)源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
cp CentOS5-Base-163.repo /etc/yum.repos.d/


#yum 升級安裝,根據(jù)需求自己行刪除
yum install -y lrzsz gcc gcc-c++ make flex autoconf automake vixie-cron libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel kernel-devel wget patch ntp libevent m4 zip unzip gd gd-devel file libtool-libs gmp-devel pspell-devel mod_perl-devel parted apr-util readline-devel sysstat vim* popt-devel patch openssh-clients net-snmp net-snmp-devel net-snmp-utils net-snmp-libs


#設(shè)置ssh下 SecureCRT標(biāo)簽顯示為帳號@IP

touch /etc/sysconfig/bash-prompt-xterm
vim  /etc/sysconfig/bash-prompt-xterm
#添加以下一行
echo -ne "\e]2;${USER}@$(/sbin/ifconfig eth0|grep 'inet addr'|sed -e 's/^.*inet addr:\(.*\) Bcast.*$/\1/')\a"


#設(shè)置term類型是screen時(命令screen進(jìn)入新窗口時)標(biāo)簽顯示內(nèi)容, 和xterm一樣
cp /etc/sysconfig/bash-prompt-xterm /etc/sysconfig/bash-prompt-screen


#設(shè)置term類型不是xterm和screen時標(biāo)簽顯示內(nèi)容, 也和xterm一樣
cp /etc/sysconfig/bash-prompt-xterm /etc/sysconfig/bash-prompt-default


#給予可執(zhí)行權(quán)限
chmod +x /etc/sysconfig/bash-prompt-*


#修改文件句柄數(shù)為65535,默認(rèn)系統(tǒng)為1024
echo "session required /lib64/security/pam_limits.so" >>/etc/pam.d/login
echo -ne "
* soft nofile 65534
* hard nofile 65534
" >>/etc/security/limits.conf


#添加iptables
rm -rf /etc/sysconfig/iptables
touch /etc/sysconfig/iptables
cat << EOF >> /etc/sysconfig/iptables
此段加入你的iptables規(guī)則
EOF

service iptables restart


#根據(jù)硬件優(yōu)化Linux性能
cat << EOF >> /etc/sysctl.conf
# Add

#開啟SYN Cookies,當(dāng)出現(xiàn)SYN等待隊列溢出時,啟用cookies來處理
net.ipv4.tcp_syncookies = 1

#表示SYN隊列的長度,默認(rèn)為1024,加大隊列長度為8192,可以容納更多等待連接的網(wǎng)絡(luò)連接數(shù)。
net.ipv4.tcp_max_syn_backlog = 65536

#每個網(wǎng)絡(luò)接口接收數(shù)據(jù)包的速率比內(nèi)核處理這些包的速率快時,允許送到隊列的數(shù)據(jù)包的最大數(shù)目
net.core.netdev_max_backlog =  262144

net.ipv4.tcp_fin_timeout = 30

#當(dāng)keepalive起用的時候,TCP發(fā)送keepalive消息的頻度。缺省是2小時
net.ipv4.tcp_keepalive_time = 1200

#redis設(shè)置
net.core.somaxconn = 262144
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0

#參數(shù)的值決定了內(nèi)核放棄連接之前發(fā)送SYN+ACK包的數(shù)量
net.ipv4.tcp_synack_retries = 2

#在內(nèi)核放棄建立連接之前發(fā)送SYN包的數(shù)量
net.ipv4.tcp_syn_retries = 2

#啟用timewait快速回收
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
#系統(tǒng)中最多有多少個TCP套接字不被關(guān)聯(lián)到任何一個用戶文件句柄上。這個限制僅僅是為了防止簡單的DoS攻擊,不能過分依靠它或者人為地減小這個值,更應(yīng)該增加這個值(如果增加了內(nèi)存之后)
net.ipv4.tcp_max_orphans = 3276800

#允許系統(tǒng)打開的端口范圍
net.ipv4.ip_local_port_range = 1024  65535


#增加系統(tǒng)文件描述符限制
fs.file-max = 65535

#允許更多的PIDs (減少滾動翻轉(zhuǎn)問題); may break some programs 32768
kernel.pid_max = 65536

# 增加TCP最大緩沖區(qū)大小
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.eth0.send_redirects = 0
net.ipv4.conf.all.send_redirects = 0


#2012-8-30
#net.ipv4.ip_conntrack_max=1048576
#net.ipv4.netfilter.ip_conntrack_max=1048576
net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait=120
net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait=60
net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait=120
net.ipv4.neigh.default.gc_thresh1=10240
net.ipv4.neigh.default.gc_thresh2=40960
net.ipv4.neigh.default.gc_thresh3=81920

#timewait的數(shù)量
net.ipv4.tcp_max_tw_buckets =6000

EOF


#刷新sysctl.conf
復(fù)制代碼 代碼如下:
/sbin/sysctl -p


#禁用ipv6
復(fù)制代碼 代碼如下:
echo -ne "alias net-pf-10 off\noptions ipv6 disable=1" >>/etc/modprobe.conf
/sbin/chkconfig --level 35 ip6tables off


#關(guān)閉 selinux
復(fù)制代碼 代碼如下:
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config


#將同步好的時間寫到CMOS里
復(fù)制代碼 代碼如下:
sed -i 's#SYNC_HWCLOCK=no#SYNC_HWCLOCK=yes#' /etc/sysconfig/ntpd


#設(shè)置同步時間
復(fù)制代碼 代碼如下:
echo "0 6 * * * /usr/sbin/ntpdate 192.168.0.172;/sbin/hwclock -w; >/dev/null 2>&1" >>/var/spool/cron/root
service crond restart


#修改系統(tǒng)啟動級別
復(fù)制代碼 代碼如下:
sed -i 's/id:5:initdefault:/id:3:initdefault:/g' /etc/inittab


#禁止ctrl+alt+del
復(fù)制代碼 代碼如下:
sed -i "s/ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/#ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/"  /etc/inittab


二:
獲取相關(guān)開源程序:
Nginx 官方當(dāng)前穩(wěn)定版為 nginx-1.2.4 ,我測試環(huán)境使用版本為nginx-1.3.3
pcre-8.31
nginx_upstream_check_module
ngx_cache_purge-1.6
請自行從網(wǎng)絡(luò)下載

安裝步驟:

#新建WWW用戶組和WWW用戶
復(fù)制代碼 代碼如下:
groupadd www
useradd -g www www -s /bin/false


#創(chuàng)建相應(yīng)的目錄
復(fù)制代碼 代碼如下:
mkdir -p /data/html/www
mkdir -p /data/proxy_temp_dir
mkdir -p /data/proxy_cache_path
mkdir -p /data/logs
chown -R www:www /data/proxy_cache_path
chown -R www:www /data/proxy_temp_dir
chown -R www:www /data/html/
chown -R www:www /data/logs


#安裝內(nèi)核和openssl
復(fù)制代碼 代碼如下:
yum -y install openssl-devel kernel-devel


#安裝Pcre
復(fù)制代碼 代碼如下:
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31
./configure --prefix=/usr/local/pcre
make
make install


#安裝nginx
復(fù)制代碼 代碼如下:
tar zxvf ngx_cache_purge-1.6.tar.gz
tar zxvf nginx-1.3.3.tar.gz
tar zxvf nginx_upstream_check_module.tar.gz
cd nginx-1.3.3
patch -p1 < /root/nginx_keepalived_install/nginx_upstream_check_module/check_1.2.2+.patch
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_realip_module --with-http_gzip_static_module --with-openssl=/usr/ --with-pcre=/root/nginx_keepalived_install/pcre-8.31 --add-module=/root/nginx_keepalived_install/ngx_cache_purge-1.6 --add-module=/root/nginx_keepalived_install/nginx_upstream_check_module
make
make install
cp /root/nginx_keepalived_install/cut_nginx_log.sh /usr/local/nginx/sbin/
chmod +x /usr/local/nginx/sbin/cut_nginx_log.sh
echo -ne "00 00 * * * /bin/bash  /usr/local/nginx/sbin/cut_nginx_log.sh" >>/var/spool/cron/root
service crond restart
chown -R www:www /usr/local/nginx/
cp /root/nginx_keepalived_install/nginx /etc/rc.d/init.d/
chmod +x /etc/rc.d/init.d/nginx
chkconfig nginx on




到這里Nginx安裝完畢,目前Nginx所有的配置都是默認(rèn)配置,我貼下我案例中的NGINX配置,如有錯誤請大牛們指導(dǎo).

Nginx.conf

復(fù)制代碼 代碼如下:

user  www  www;
worker_processes 8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
worker_rlimit_nofile 204800;

error_log  /data/logs/error.log;

pid        logs/nginx.pid;


events {
    worker_connections  240800;
    use epoll;
}


http {
    include   nginx_load_balance.conf;
    #include    proxy.conf;
    include       mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size 128;

    #log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             #'$status $body_bytes_sent "$http_referer" '
             #'"$http_user_agent" $http_x_forwarded_for';
    #access_log  /data/logs/access.log  access;

    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay on;
    server_tokens off;
    keepalive_timeout 60;
    client_header_buffer_size 4k;
    #large_client_header_buffers 4 32k;
    client_max_body_size 10m;

    client_header_timeout  120s;
    client_body_timeout    120s;
    send_timeout           120s;

    gzip  off;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    output_buffers   1 512k;
    postpone_output  1460;
    #gzip_http_version 1.1;
    gzip_comp_level 4;
    gzip_types text/plain text/css text/javascript text/xml application/x-javascript application/xml application/xml+rss;
    gzip_vary on;

    server {
        listen       80;
        server_name  localhost;

        location / {
            rewrite ^ http://www.test.com$request_uri?;
      #root   /data/html/www;
            #index  index.html index.htm;
        }

        error_page  404              /data/html/www/404.html;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location /status {
        stub_status on;
  access_log  off;
        }
  location /nstatus {
        check_status;
        access_log off;
        #allow SOME.IP.ADD.RESS;
        #deny all;
        }

    }
    include  vhost/*.conf;
}



nginx_load_balance.conf

復(fù)制代碼 代碼如下:
    upstream dx {
    ip_hash;
    server 192.168.0.11:80;
    server 192.168.0.12:80;
    server 192.168.0.13:80;
    server 192.168.0.14:80;
    server 192.168.0.15:80;
    check interval=3000 rise=2 fall=8 timeout=3000 type=http;
    check_http_send "GET / HTTP/1.0\r\n\r\n";
    check_http_expect_alive http_2xx http_3xx http_4xx;
    #server 192.168.0.30:80; backup;
    }


    upstream lt {
    ip_hash;
    server 192.168.1.11:80;
    server 192.168.1.12:80;
    server 192.168.1.13:80;
    server 192.168.1.14:80;
    server 192.168.1.15:80;
    check interval=3000 rise=2 fall=8 timeout=3000 type=http;
    check_http_send "GET / HTTP/1.0\r\n\r\n";
    check_http_expect_alive http_2xx http_3xx http_4xx;
    #server 192.168.1.30:80; backup;
    }


proxy.conf
復(fù)制代碼 代碼如下:
proxy_temp_path   /data/proxy_temp_dir;   #指定臨時文件目錄
proxy_cache_path  /data/proxy_cache_path levels=1:2 keys_zone=cache_one:2000m inactive=1d max_size=1g;
client_body_buffer_size  512k; #增加緩沖區(qū)代理緩沖客戶端請求的最大字節(jié)數(shù)
proxy_connect_timeout    60;   #增加連接后端服務(wù)器超時時間
proxy_read_timeout       60;   #增加后端服務(wù)器響應(yīng)請求超時時間
proxy_send_timeout       60;   #增加后端服務(wù)器發(fā)送數(shù)據(jù)超時時間
proxy_buffer_size        32k;   #增加代理請求緩存區(qū)大小
proxy_buffers           4 64k;  #增加
proxy_busy_buffers_size 128k;   #增加系統(tǒng)繁忙時可申請的proxy_buffers大小
proxy_temp_file_write_size 128k;  #增加proxy緩存臨時文件的大小
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;   #增加故障轉(zhuǎn)移,如果后端的服務(wù)器返回502、504、執(zhí)行超時等錯誤,自動將請求轉(zhuǎn)發(fā)到upstream負(fù)載均衡池中的另一臺服務(wù)器,實現(xiàn)故障轉(zhuǎn)移。
proxy_cache cache_one;  #增加使用web緩存區(qū)cache_one


以上是Nginx配置,下面是vhost中網(wǎng)站配置
xxxx_com.conf

復(fù)制代碼 代碼如下:
server
{
listen       192.168.0.1;
server_name  xxx.com;

access_log  /data/logs/dx.log  dx;

location /
     {
      proxy_next_upstream http_502 http_504 error timeout invalid_header;
     # proxy_cache cache_one;
     # proxy_cache_valid  200 304 12h;
     # proxy_cache_key $host$uri$is_args$args;
     proxy_set_header Host $http_host;
     #proxy_set_header X-Real-IP $remote_addr;
     # proxy_set_header X-Forwarded-For $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_headers_hash_max_size 51200;
      proxy_headers_hash_bucket_size 6400;

      proxy_pass http://dx;

      #if ($request_uri ~* "^/upload/") {
      #add_header Cache-Control 'max-age=86400';
      #}

      location ~* \.(gif|jpg|jpeg|png|flv|swf|ico)$
      {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://dx;
      add_header Cache-Control 'max-age=86400';
      }

      location ~* \.(js)$
      {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://dx;
      add_header Cache-Control 'max-age=600';
      }

      #expires      -1;
      add_header Cache-Control 'no-store, no-cache, must-revalidate';
      add_header Pragma no-cache;
      }

  location ~ /purge(/.*)
    {
     allow            127.0.0.1;
     allow            192.168.0.0/16;
     deny            all;
     #proxy_cache_purge    cache_one   $host$1$is_args$args;
    }

    location ~ .*\.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$
    {
         proxy_set_header Host $http_host;
         #proxy_set_header X-Forwarded-For  $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_pass http://dx;
    }

}

server
{
listen       192.168.1.1;
server_name xxxx.com;

access_log  /data/logs/lt.log  lt;

location /
     {
      proxy_next_upstream http_502 http_504 error timeout invalid_header;
      #proxy_cache cache_one;
      #proxy_cache_valid  200 304 12h;
      #proxy_cache_key $host$uri$is_args$args;
      proxy_set_header Host $http_host;
      #proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_headers_hash_max_size 51200;
      proxy_headers_hash_bucket_size 6400;
      proxy_pass http://lt;

      #if ($request_uri ~* "^/upload/") {
      #add_header Cache-Control 'max-age=86400';
      #}

      location ~* \.(gif|jpg|jpeg|png|flv|swf|ico)$
      {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://lt;
      add_header Cache-Control 'max-age=86400';
      }

      location ~* \.(js)$
      {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://lt;
      add_header Cache-Control 'max-age=600';
      }

      #expires      -1;
      add_header Cache-Control 'no-store, no-cache, must-revalidate';
      add_header Pragma no-cache;
      }

  location ~ /purge(/.*)
    {
     allow            127.0.0.1;
     allow            192.168.0.0/16;
     deny            all;
     #proxy_cache_purge    cache_one   $host$1$is_args$args;
    }

    location ~ .*\.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$
    {
         proxy_set_header Host $http_host;
         #proxy_set_header X-Forwarded-For  $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_pass http://lt;
    }

}


至此,一套完整的Nginx反向代理全部結(jié)束.



網(wǎng)站無法打開排查

1:ping域名看解析是否正常且是否連通.

2:配置本機(jī)Hosts指向后端單機(jī)IIS查看網(wǎng)站是否正常訪問.

3:檢查前端Nginx進(jìn)程和端口是否存在,
ps -ef |grep nginx
netstat -an |grep 80


系統(tǒng)相關(guān)配置

Nginx
Nginx目錄/usr/local/nginx/
/usr/local/nginx/conf/nginx.conf Nginx主配置文件
/usr/local/nginx/conf/nginx_load_balance.conf Nginx反向代理輪詢配置文件
/usr/local/nginx/conf/proxy.conf Nginx緩存配置相關(guān)
/usr/local/nginx/conf/vhost/ Nginx虛擬主機(jī)配置目錄

Snmp
/etc/snmp/snmpd.conf

日志切割

/root/scripts/ 所有日志切割腳本都在這個目錄
crontab -l 列出計劃任務(wù)
crontab -e 編輯計劃任務(wù)

系統(tǒng)相關(guān)操作

Nginx
重啟Nginx service nginx restart
重載Nginx配置文件 service nginx reload
檢測Nginx配置語法是否正確 /usr/local/nginx/sbin/nginx -t
關(guān)閉Nginx service nginx stop
啟動Nginx service nginx start

Snmp
重啟Snmp service snmpd restart
關(guān)閉Snmp service snmpd stop
啟動Snmp service snmpd start
最后編輯: chen 編輯于2012/11/07 17:57

相關(guān)文章

  • nginx的location配置導(dǎo)致網(wǎng)關(guān)返回404問題

    nginx的location配置導(dǎo)致網(wǎng)關(guān)返回404問題

    這篇文章主要介紹了nginx的location配置導(dǎo)致網(wǎng)關(guān)返回404問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-06-06
  • 分享nginx+php-fpm實現(xiàn)大文件下載排坑的過程

    分享nginx+php-fpm實現(xiàn)大文件下載排坑的過程

    這篇文章主要介紹了nginx+php-fpm實現(xiàn)大文件下載排坑的過程,文中通過代碼實例相結(jié)合的形式給大家介紹的非常詳細(xì),具有一定得參考借鑒價值,需要的朋友參考下吧
    2018-08-08
  • 詳解nginx靜態(tài)資源服務(wù)器簡單配置

    詳解nginx靜態(tài)資源服務(wù)器簡單配置

    這篇文章主要介紹了詳解nginx靜態(tài)資源服務(wù)器簡單配置,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • 使用AWS的ELB服務(wù)時為Nginx啟用代理協(xié)議的步驟講解

    使用AWS的ELB服務(wù)時為Nginx啟用代理協(xié)議的步驟講解

    這篇文章主要介紹了使用AWS的ELB服務(wù)時為Nginx啟用代理協(xié)議的步驟講解,ELB服務(wù)是亞馬遜服務(wù)器提供的常用的負(fù)載均衡方案,需要的朋友可以參考下
    2015-12-12
  • 利用nginx和騰訊云免費證書制作https的方法

    利用nginx和騰訊云免費證書制作https的方法

    這篇文章主要介紹了利用nginx和騰訊云免費證書制作https的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-11-11
  • Nginx學(xué)習(xí)筆記之事件驅(qū)動框架處理流程

    Nginx學(xué)習(xí)筆記之事件驅(qū)動框架處理流程

    Nginx對請求的處理是通過事件觸發(fā)的,模塊作為事件消費者,只能被事件收集、分發(fā)器調(diào)用。在Nginx中,接收到一個請求時,不會產(chǎn)生一個單獨的進(jìn)程來處理該請求,而是由事件收集、分發(fā)器(進(jìn)程)調(diào)用某個模塊,由模塊處理請求,處理完后再返回到事件收集、分發(fā)器
    2014-07-07
  • Linux\Nginx 環(huán)境下虛擬域名配置及測試驗證

    Linux\Nginx 環(huán)境下虛擬域名配置及測試驗證

    這篇文章主要介紹了Linux\Nginx 虛擬域名配置及測試驗證的步驟詳解,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-11-11
  • nginx配置IP白名單的詳細(xì)步驟

    nginx配置IP白名單的詳細(xì)步驟

    在日常運維工作中會碰到這樣的需求,設(shè)置網(wǎng)站訪問只對某些ip開放,其他ip的客戶端都不能訪問,下面這篇文章主要給大家介紹了關(guān)于nginx配置IP白名單的詳細(xì)步驟,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2022-12-12
  • Nginx中split_clients模塊的使用

    Nginx中split_clients模塊的使用

    split_clients模塊可以輕松地實現(xiàn)A/B測試,本文主要介紹了Nginx中split_clients模塊的使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-06-06
  • Nginx 域名轉(zhuǎn)發(fā)的實現(xiàn)

    Nginx 域名轉(zhuǎn)發(fā)的實現(xiàn)

    這篇文章主要介紹了Nginx 域名轉(zhuǎn)發(fā)的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08

最新評論