首先;html
安裝Nginxnginx
vim nginx.conf(反向代理)vim
[root@wangxiong conf]# /usr/local/nginx/sbin/nginx服務器
[root@wangxiong conf]# vim /etc/hostsapp
[root@wangxiong html]# mkdir www
[root@wangxiong html]# ls
50x.html index.html www
[root@wangxiong html]# echo "`hostname -I` www.yunjisuan.com" > www/index.html
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.168 yyy.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.169 yyy.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.168 yyy.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.169 yyy.yunjisuan.comcurl
而後作兩個Web1和Web2服務器url
安裝Nginx--spa
步驟同樣進入 Vim nginx,conf裏修改代理
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr-$remote_user[$time_local]"$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';
server {
listen 80;
server_name yyy.yunjisuan.com;
location / {
root html/yyy;
index index.html index.htm;
}
}
server {
listen 80;
server_name www.yunjisuan.com;
location / {
root html/www;
index index.html index.htm;orm
}
access_log logs/access_www.log main;
}
}
[root@wangxiong conf]# /usr/local/nginx/sbin/nginx
[root@wangxiong conf]# cd ..
[root@wangxiong nginx]# cd html/
[root@wangxiong html]# mkdir www yyy
[root@wangxiong html]# ls
50x.html index.html www yyy
[root@wangxiong html]# echo "`hostname -I` yyy.yunjisuan.com" > yyy/index.html
[root@wangxiong html]# echo "`hostname -I` www.yunjisuan.com" > www/index.html
[root@wangxiong html]# vim /etc/hosts
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.168 www.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.168 www.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.168 www.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.168 www.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.168 www.yunjisuan.com
[root@wangxiong html]# curl yyy.yunjisuan.com
192.168.81.168 yyy.yunjisuan.com
[root@wangxiong html]# curl yyy.yunjisuan.com
192.168.81.168 yyy.yunjisuan.com
一樣;Web2也是進入Vim nginx.conf裏修改配置文件
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr-$remote_user[$time_local]"$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';
server {
listen 80;
server_name yyy.yunjisuan.com;
location / {
root html/yyy;
index index.html index.htm;
}
}
server {
listen 80;
server_name www.yunjisuan.com;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/access_www.log main;
}
}
[root@wangxiong conf]# /usr/local/nginx/sbin/nginx
[root@wangxiong conf]# cd ..
[root@wangxiong nginx]# cd html/
[root@wangxiong html]# mkdir www yyy
[root@wangxiong html]# ls
50x.html index.html www yyy
[root@wangxiong html]# echo "`hostname -I` www.yunjisuan.com" > www/index.html
[root@wangxiong html]# echo "`hostname -I` yyy.yunjisuan.com" > yyy/index.html
[root@wangxiong html]# vim /etc/hosts
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.169 www.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.169 www.yunjisuan.com
[root@wangxiong html]# curl www.yunjisuan.com
192.168.81.169 www.yunjisuan.com
[root@wangxiong html]# curl yyy.yunjisuan.com
192.168.81.169 yyy.yunjisuan.com
[root@wangxiong html]# curl yyy.yunjisuan.com
192.168.81.169 yyy.yunjisuan.com
若是在作的時候80端口拼不出來能夠選擇下列的方法