Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Varnish2 proxy multiple back-end servers

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Vi / usr/local/varnish/default.vcl

Locate and modify the following:

Vcl 4.0

Import directors; / / add a new line and import a directors

-add business server nodes as follows-

Backend web1 {# modifies default to web1, which is the later web server. If there are several web nodes, just copy a few backend domains.

.host = "192.168.80.103"; # address of the backend web server

.port = "80"; # web server port

}

Backend web2 {

.host = "192.168.80.104"

.port = "80"

}

-then the above code then defines the scheduling algorithm and specifies traffic forwarding-

Sub vcl_init {# is defined in the in subfunction

New bar = directors.round_robin (); / / random (random) round_robin dns

# define the server group and make the new bar equal to the previously defined variable directors, followed by the rr algorithm

Bar.add_backend (web1); # Note how many backend are added here

Bar.add_backend (web2)

}

Sub vcl_recv {

Set req.backend_hint = bar.backend (); / / Traffic is forwarded to all nodes. Pay attention to parentheses.

}

Pkill-9 varnish

Netstat-anpt | grep varnishd

Varnishd-f / usr/local/varnish/default.vcl

Netstat-anpt | grep varnishd

Open another web server on the Linux system (192.168.80.103):

Yum install httpd-y

Vi / etc/httpd/conf/httpd.conf

End-of-line mode / ServerName remove the previous comments and save exit

Systemctl start httpd

Vi / var/www/html/index.html

Service 2

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report