Score:0

How to add NGINX upstream to a serverpilot install?

ps flag

I want to load balance a Serverpilot install between 2 servers. The config doesn't seem to use any 'upstream' so I'm confused about how to add it. This is what i have:

/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;
}

I want to add the current server IP and a new IP to an upstream so Nginx round robin between the 2 instead of using the sole server. I hope that makes sense.

in flag
Does this answer your question? [Nginx round-robin nor exactly round-robin](https://serverfault.com/questions/895116/nginx-round-robin-nor-exactly-round-robin)
Michael Rogers avatar
ps flag
Should i simply add the upstream above the server and change main.conf proxy_pass to point to that upstream?
djdomi avatar
za flag
@geraldschneider please provide the full answer ,it solves the question ;)
in flag
@djdomi I casted a close vote, the comment is added automatically. When others confirm the vote the question will be closed as a duplicate. There is no need to add the same answer again.
djdomi avatar
za flag
your right ,i did the same
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.