nginx web hosting applications []

Nginx Main applications:

 Static web server

 Load Balancing

Static Proxy
Hosting

 

Web Hosting

  : Web Hosting, is to a physical server into multiple "virtual" servers, so we have one physical server can be used as multiple servers, so you can configure multiple sites;

Nginx Virtual Host feature, is to let us do not need to install multiple Nginx, you can run multiple sites;
the next Nginx, a server is a virtual host label;
nginx web host is through nginx.conf specified in the server node , you want to set up multiple virtual hosts, you can configure multiple server nodes;
configure virtual hosts via the following two ways:
  1, based virtual hosting
based virtual hosting is the most common form of web hosting.
  {Server
    the listen 80;
      server_name www.MyWeb.com;
  LOCATION / MyWeb {
      proxy_pass http://www.myweb.com;
    }
  }
  Server {
    the listen 80;
    server_name www.p2p.com;
      LOCATION / P2P {
        proxy_pass HTTP: // www.p2p.com;
      }
  }
need to modify the local hosts file, file location: C: \ Windows \ System32 \
drivers \ etc \ hosts configured in the hosts file: 192.168.208.128 www.myweb.com
In the hosts file configuration: 192.168.208.128 www.p2p.com
front of the Linux IP, followed by your custom domain name
-based virtual host port
-based virtual host port configuration, use the port to differentiate;
browser using the same domain name + the same port or a port access address + ip;
  Server {
    the listen 8080;
      server_name www.MyWeb.com;
      LOCATION / MyWeb {
        proxy_pass http://www.myweb.com;
      }
  }
  Server {
    the listen 9090;
    server_name www.MyWeb.com ;
      LOCATION / P2P {
      proxy_pass http://www.p2p.com;
    }
  }
virtual host example
of urban sites sites (to illustrate, we configure three city sites)

1, configure three Tomcat, tomcat each site, project deployment ROOT directory under the tomcat;
2, 3 Nginx virtual host configuration:
Method 1:
Add three nodes nginx.conf file server, three for configuring the virtual host
{Server
the listen 80;
server_name beijing.myweb.com;
LOCATION / {
proxy_pass http://beijing.myweb.com;
}
}
Server {
the listen 80;
server_name nanjing.myweb.com;
LOCATION / {
proxy_pass HTTP: // Nanjing. myweb.com;
}
}
Server {
the listen 80;
server_name tianjin.myweb.com;
LOCATION / {
proxy_pass http://tianjin.myweb.com;
}
}
way:
redistribute the virtual host include by way
include / usr / local / Nginx / Vhost / the files vhost.conf ;
the virtual directory is added to the configuration file "http {}" of the end portion, in parallel with the other server;
. 3, each virtual host configuration requests corresponding to the back-end server forwards the
upstream beijing.myweb .com {
127.0.0.1:9910 Server;
}
upstream nanjing.myweb.com {
Server 127.0.0.1:9920;
}
upstream tianjin.myweb.com {
Server 127.0.0.1:9930;
}
. 4, modify the hosts file, point to allow the Linux ip a domain name three sites
192.168.230.128 beijing.myweb.com
192.168.230.128 nanjing.myweb.com
192.168.230.128 tianjin.myweb.com

 

Guess you like

Origin www.cnblogs.com/yhm9/p/11183631.html
Recommended