D
D
DevLearn2020-03-02 13:48:44
Nginx
DevLearn, 2020-03-02 13:48:44

Setting up Nginx and Apache, setting up the upstream module?

Good afternoon. Need help. The task is the following:

"Configure nginx as a balancer. Using mod_upstream, distribute all incoming traffic across three Apache2 servers located in the local network"

I understand correctly. That I need to install apache in the amount of 3 pieces. (for example, on a virtual box). And then using Nginx to scatter traffic over them? What kind of test site is needed for this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey V, 2020-03-02
@DevLearn

on a purely theoretical side, you can simplify and run one Apache, which will listen to three different ports, the nginx config will practically not change (instead of different ip there will be different port numbers) - however, this will greatly simplify your life at the configuration stage - you won’t have to fight also with virtual machines and their networks.
all this can be done on one machine, for example:
apache-host-1 listens on port 8081;
apache-host-2 is listening on port 8082;
apache-host-3 is listening on port 8083;
nginx listens on port 80 and proxies requests for these three upstreams;
test site - elementary three different folders with index.html file and content: <h1>808x</h1>(replace x with the corresponding number)
each Apache host is set to its own folder and when accessed by the port number in the browser, it will show "its own" port number. The
end result: when accessing port 80 through the browser, the port numbers of different Apache hosts are displayed alternately.
If you work out this script, then spread it all over 4 different virtual machines - the task of purely administering virtual machines - the web server configs will already be ready for you

K
ky0, 2020-03-02
@ky0

Yes, you understand correctly.
You can limit yourself to one Apache by creating separate virtual hosts on different ports and / or adding additional IPs - for test purposes it doesn't matter.

V
Vladislav, 2020-03-02
@Jewish_Cat

If it’s simple, then you will have one wheelbarrow (server) on it Nginx with upstream configured for the site test.ru

upstream backend {
    server backend1.example.com;
    server backend2.example.com;
}

server {

    server_name test.ru;
    location / {
        proxy_pass http://backend;
    }
}

And plus 3 cars on each apache is installed and the same site works.
This nginx config is the simplest. On the off-site in the documentation, everything is clear and all options are described in detail

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question