我想在 2 台服务器之间平衡 Serverpilot 的负载。配置似乎没有使用任何“上游”,所以我对如何添加它感到困惑。这是我所拥有的:
/etc/nginx-sp/vhosts.d/server1.conf
server {
listen 80;
listen [::]:80;
server_name
sv1.domain.com
;
root /srv/users/serverpilot/apps/server1/public;
access_log /srv/users/serverpilot/log/server1/server1_nginx.access.log main;
error_log /srv/users/serverpilot/log/server1/server1_nginx.error.log;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
include /etc/nginx-sp/vhosts.d/server1.d/*.nonssl_conf;
include /etc/nginx-sp/vhosts.d/server1.d/*.conf;
}
/etc/nginx-sp/vhosts.d/server1.d/main.conf
location / {
proxy_pass $backend_protocol://$backend_host:$backend_port;
}
我想将当前服务器 IP 和新 IP 添加到上游,以便 Nginx 在两者之间循环,而不是使用唯一的服务器。我希望这是合理的。