发表于 2018-11-16 08:05:55

nginx基于IP-12177655

  基于IP的虚拟主机
  首先添加3个IP
  # 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:131Link encap:EthernetHWaddr 00:0C:29:74:18:24
  inet addr:172.20.100.131Bcast:172.20.103.255Mask:255.255.252.0
  UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
  eth0:132Link encap:EthernetHWaddr 00:0C:29:74:18:24
  inet addr:172.20.100.132Bcast:172.20.103.255Mask:255.255.252.0
  UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
  eth0:133Link encap:EthernetHWaddr 00:0C:29:74:18:24
  inet addr:172.20.100.133Bcast:172.20.103.255Mask:255.255.252.0
  UP BROADCAST RUNNING MULTICASTMTU:1500Metric:1
  # vim extra/nginx_vhosts.conf
  server {
  listen       172.20.100.133:8060;
  server_name172.20.100.133;
  location / {
  root   /data0/www/www;
  indexindex.html index.htm;
  access_log /app/logs/www_access.logcommonlog;
  }
  }
  ######
  server {
  listen       172.20.100.132:8070;
  server_name172.10.100.132;
  location / {
  root   /data0/www/bbs;
  indexindex.html index.htm;
  access_log /app/logs/bbs_access.logcommonlog;
  }
  }
  ######
  server {
  listen       172.20.100.131:8080;
  server_name172.10.100.131;
  location / {
  root   /data0/www/blog;
  indexindex.html index.html;
  access_log /app/logs/blog_access.logcommonlog;
  }
  }
  server {
  listen       80;
  server_namestatus.you.com;
  location / {
  stub_status on;
  access_log off;
  }
  }
  # ../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

  # ../sbin/nginx -s>
页: [1]
查看完整版本: nginx基于IP-12177655