Nginx反向代理+DNS轮询+IIS7.5 千万PV 百万IP 双线 网站架构案例

2019-10-17 21:11:20丽君

请自行从网络下载

安装步骤:

#新建WWW用户组和WWW用户
groupadd www
useradd -g www www -s /bin/false

#创建相应的目录
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

#安装内核和openssl
yum -y install openssl-devel kernel-devel

#安装Pcre
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31
./configure --prefix=/usr/local/pcre
make
make install

#安装nginx
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所有的配置都是默认配置,我贴下我案例中的NGINX配置,如有错误请大牛们指导.

Nginx.conf


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';