nginx基於IP

基於IP的虛擬主機

首先添加3個IP


[root@localhost extra]# ifconfig

ifconfig eth0:133 172.20.100.133 netmask 255.255.252.0 up

ifconfig eth0:132 172.20.100.132 netmask 255.255.252.0 up

ifconfig eth0:131 172.20.100.131 netmask 255.255.252.0 up


eth0:131  Link encap:Ethernet  HWaddr 00:0C:29:74:18:24  

          inet addr:172.20.100.131  Bcast:172.20.103.255  Mask:255.255.252.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1


eth0:132  Link encap:Ethernet  HWaddr 00:0C:29:74:18:24  

          inet addr:172.20.100.132  Bcast:172.20.103.255  Mask:255.255.252.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1


eth0:133  Link encap:Ethernet  HWaddr 00:0C:29:74:18:24  

          inet addr:172.20.100.133  Bcast:172.20.103.255  Mask:255.255.252.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1


[root@localhost nginx]# vim extra/nginx_vhosts.conf

    server {

        listen       172.20.100.133:8060;

        server_name  172.20.100.133;

        location / {

            root   /data0/www/www;

            index  index.html index.htm;

            access_log /app/logs/www_access.log  commonlog;

        }

    }

######

server {

        listen       172.20.100.132:8070;

        server_name  172.10.100.132;

        location / {

            root   /data0/www/bbs;

            index  index.html index.htm;

            access_log /app/logs/bbs_access.log  commonlog;

        }

    }

######

server {

        listen       172.20.100.131:8080;

        server_name  172.10.100.131;

        location / {

            root   /data0/www/blog;

            index  index.html index.html;

            access_log /app/logs/blog_access.log  commonlog;

        }

    }

server {

        listen       80;

        server_name  status.you.com;

        location / {

          stub_status on;

          access_log off;

        }

    }



[root@localhost extra]# ../sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[root@localhost extra]# ../sbin/nginx -s reload


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章