The first step to install nginx on the server is as follows:
Install nginx tutorial connection
The second step is to open nginx.conf and edit:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 10m;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
}
upstream mycluster{
server 8.562.56.44:9005; #服务器1
server 45.265.451.456:9006 weight=3; #服务器2 weight值越大负载的权重越大,默认为1
}
server {
listen 80;
server_name 8.562.56.44;
location / {
proxy_pass http://mycluster;
}
}
}