V
V
Victor2016-04-13 11:16:10
Nginx
Victor, 2016-04-13 11:16:10

How to competently “move” to Nginx + Apache?

Hi all!
Such a thing, there is a web server with Apache hosting 100+ small sites, suddenly it was necessary to put "Nginx" in front of Apache so that it (Nginx) distributes statics. The question is, what is it, should I now create these 100+ virtual hosts on nginx so that it can handle all this? Maybe someone already has experience with a belated upgrade of a web server?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dimonchik, 2016-04-13
@estoy

well, how else? 80th - then there is only one port, you can’t share it
1) set nginx to 8080 or 81 or whatever you want
2) manually write all the configs in one file or beat it into parts as you like in the sites-enabled folder (it is not necessary to call by domain names, but, of course , which is easier to maintain), but you can quickly copy-paste in one sheet
3) in the configs you prescribe where to pull the statics for each domain and proxy for Apache
4) you test, change ports with Apache in places

E
Evgeny Bezymyannikov, 2016-04-13
@psman

Variables can be used in Apache config. For example, use /var/www/+hostname/log|data|www as the path to the site

A
Alexander Abakumov, 2016-04-22
@nops

You will have to prescribe a config for each site. You can write a small script in bash, feed it a sample, according to which it will form the main horse (or several, according to the site names). To write a script, it will take 10-15 minutes at most, and to rewrite each config with your hands, much longer. Moreover, it’s easy to get confused and poke the wrong thing.
the logic is as follows:
1. You start parsing the Apache config, pull out the site names from it and add it to a temporary file $file=/tmp/$RANDOM
2. You start a loop in which you query the created file $file and read each site line by line, writing it to a variable, say $domainname.
3 inside the loop, you copy the contents of the nginx config source file, replacing a certain expression inside the config, say DOMAIN_NAME, with the value of the $domainname variable.
Preparatory work: Creation of the initial config, inside of which a code word is added instead of the site address, say DOMAIN_NAME, which we can later use sed to replace.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question