基礎營運:基於IP實現網頁分流

來源:互聯網
上載者:User

標籤:roo   pad   ipad   red   ppp   com   alias   device   RoCE   

一、說明

想要流量分流,在一個介面上設定多IP的方式,是可以實現的,在互連網上需要訪問的網域名稱,一般人並不知道什麼是IP,就是知道IP,可能他們理解的IP(知識財產權)跟你理解的IP(互連網協議)並不一樣。基於IP的分流,目的在於訪問這些IP時開啟的網頁是一致的。分流網頁有很多種,這隻是其中的一種而已。

二、多IP設定

1.複製網路設定檔

[[email protected] ~]# cd /etc/sysconfig/network-scripts/[[email protected] network-scripts]# lsifcfg-ens33  ifdown-isdn      ifdown-tunnel  ifup-isdn    ifup-Teamifcfg-lo     ifdown-post      ifup           ifup-plip    ifup-TeamPortifdown       ifdown-ppp       ifup-aliases   ifup-plusb   ifup-tunnelifdown-bnep  ifdown-routes    ifup-bnep      ifup-post    ifup-wirelessifdown-eth   ifdown-sit       ifup-eth       ifup-ppp     init.ipv6-globalifdown-ippp  ifdown-Team      ifup-ippp      ifup-routes  network-functionsifdown-ipv6  ifdown-TeamPort  ifup-ipv6      ifup-sit     network-functions-ipv6[[email protected] network-scripts]# cp ifcfg-ens33 ifcfg-ens33:1

2.修改設定檔

[[email protected] network-scripts]# vim ifcfg-ens33:1TYPE="Ethernet"BOOTPROTO="dhcp"NAME="ens33:1"DEVICE="ens33:1"ONBOOT="yes"IPADDR=192.168.116.100PREFIX=24GATEWAY=192.168.116.255[[email protected] network-scripts]# 

3.重啟網路服務

[[email protected] network-scripts]# systemctl restart network[[email protected] network-scripts]# ip a1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00    inet 127.0.0.1/8 scope host lo       valid_lft forever preferred_lft forever    inet6 ::1/128 scope host        valid_lft forever preferred_lft forever2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000    link/ether 00:0c:29:47:c4:9f brd ff:ff:ff:ff:ff:ff    inet 192.168.116.129/24 brd 192.168.116.255 scope global noprefixroute dynamic ens33       valid_lft 1798sec preferred_lft 1798sec    inet 192.168.116.100/24 brd 192.168.116.255 scope global secondary noprefixroute ens33:1       valid_lft forever preferred_lft forever    inet6 fe80::ab30:473d:fe9e:9d7e/64 scope link noprefixroute        valid_lft forever preferred_lft forever[[email protected] network-scripts]# 

4.本地測試網路連通性

[C:\~]$ ping 192.168.116.100正在 Ping 192.168.116.100 具有 32 位元組的資料:來自 192.168.116.100 的回複: 位元組=32 時間<1ms TTL=64來自 192.168.116.100 的回複: 位元組=32 時間<1ms TTL=64來自 192.168.116.100 的回複: 位元組=32 時間<1ms TTL=64來自 192.168.116.100 的回複: 位元組=32 時間<1ms TTL=64192.168.116.100 的 Ping 統計資訊:    資料包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),往返行程的估計時間(以毫秒為單位):    最短 = 0ms,最長 = 0ms,平均 = 0ms[C:\~]$ 
三、網頁分流

1.設定網頁

[[email protected] nginx]# mkdir /server/web/test1[[email protected] nginx]# mkdir /server/web/test2[[email protected] nginx]# mv /server/web/index.html  test1/      test2/      [[email protected] nginx]# cp /server/web/index.html  /server/web/test1/[[email protected] nginx]# cp /server/web/index.html  /server/web/test2/[[email protected] nginx]# cat /server/web/index.html <h1 align=center>vhost</h1>[[email protected] nginx]# vim /server/web/test2/index.html [[email protected] nginx]# cat /server/web/test2/index.html <h1 align=center>test2 vhost</h1>[[email protected] nginx]# 

2.建立NGINX設定檔

[[email protected] nginx]# lsconf  html  logs  sbin[[email protected] nginx]# cd conf/[[email protected] conf]# lsfastcgi.conf            koi-utf             nginx.conf           uwsgi_paramsfastcgi.conf.default    koi-win             nginx.conf.default   uwsgi_params.defaultfastcgi_params          mime.types          scgi_params          win-utffastcgi_params.default  mime.types.default  scgi_params.default[[email protected] conf]# mkdir vhost[[email protected] conf]# vim nginx.confinclude vhost/*.conf;   #在最後括弧上添加[[email protected] conf]# lsfastcgi.conf            koi-utf             nginx.conf           uwsgi_paramsfastcgi.conf.default    koi-win             nginx.conf.default   uwsgi_params.defaultfastcgi_params          mime.types          scgi_params          vhostfastcgi_params.default  mime.types.default  scgi_params.default  win-utf[[email protected] conf]# cd vhost/[[email protected] vhost]# lstest1.conf  test2.conf[[email protected] vhost]# cat test1.conf server {    listen 80;    server_name 192.168.116.129 ;    index   index.html index.htm index.php;    root  /server/web/test1 ;}[[email protected] vhost]# cat test2.conf server {    listen 80;    server_name 192.168.116.100 ;    index   index.html index.htm index.php;    root  /server/web/test2 ;}[[email protected] vhost]# 

3.重啟NGINX服務

[[email protected] vhost]# /usr/local/nginx/sbin/nginx -s reload如果是第一次啟動NGINX服務,執行這條命令:[[email protected] vhost]# /usr/local/nginx/sbin/nginx

4.訪問網頁

5.設定訪問同一個網頁

[[email protected] vhost]# vim /server/web/index.html [[email protected] vhost]# cat  /server/web/index.html <h1 align=center>test1 and test2 share  web page</h1>[[email protected] vhost]# vim test2.conf [[email protected] vhost]# vim test1.conf [[email protected] vhost]# /usr/local/nginx/sbin/nginx -s reload[[email protected] vhost]# cat test1.conf server {    listen 80;    server_name 192.168.116.129 ;    index   index.html index.htm index.php;    root  /server/web ;}[[email protected] vhost]# cat test2.conf server {    listen 80;    server_name 192.168.116.100 ;    index   index.html index.htm index.php;    root  /server/web ;}[[email protected] vhost]# 

6.訪問網頁

至此基於IP實現網頁分流已完成

基礎營運:基於IP實現網頁分流

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.