T
T
technology-online2015-03-18 00:11:11
Nginx
technology-online, 2015-03-18 00:11:11

Is servername correct Configuring Nginx as Frontend to Apache Web Server?

I'm looking at the setup instructions. Some
listen 80;
server_name .site.ru
in others
server_name localhost
in the third
server_name _
And how is it right and why?
nginx.org/ru/docs/http/request_processing.html
So I read it, and, given that server_name indicates the instruction for processing nginx, I came to the conclusion that localhost should be specified, since the task of nginx is to release the apache server. And apache should apparently return localhost. Or have I misunderstood something?
On the other hand, given that the instruction says
location / {
proxy_pass 127.0.0.1:81/;
That apparently all the same the request goes to the apache server, which means that the name of the site should be indicated in the server_name. If so, how to specify server_name for all sites. And how does it actually happen?
I need Apache because I write scripts not only for myself. In general, I read the documentation, and based on the documentation, I asked questions here. All external requests are given and received by nginx. Those. it accepts a request looks
listen 80;
server_name .site.ru,
sees that the request came from such and such a site. So instead of .site.ru there should be some universal variable that passes this case
location / {
proxy_pass 127.0.0.1:81/;
Which redirects the request to 127.0.0.1:81, i.e. is obtained by the apache server, and the server processes it, gives it to Nginx and is released, and nginx already gives the finished pages to the client. But on the other hand, it is possible that
server_name localhost
is written just so that nginx accepts requests from apache, processes them and sends them to the client.
Thirdly, it is quite possible that
server_name localhost
server_name _ Serve
just so that, as it is written in the documentation
, "this is just one of the many incorrect domain names that will never intersect with any of the real names"
It is not clear why it may be necessary to write a similar server_name at all, if it never intersects in reality, then there is nothing to process. Another thing is that, for example, it is possible that the latest server_name instruction, regardless of the name, is processed without fail, and it doesn’t matter what to specify there.
And how it really is, I hoped that they would explain to me here. And I hope not for ambiguous answers like yes or no

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nazar Mokrinsky, 2015-03-18
@nazarpc

1) I recommend that you specify the name of the specific domain that you need, about localhost, and so it’s clear, about the dot at the beginning and _ read the doc, everything is written there in detail
2) Apache is almost never needed, just transfer the rules from .htaccess to similar rules in Nginx virtual host (for popular systems, you can find a ready-made config) and do not worry too much

T
technology-online, 2015-03-18
@technology-online

I do not have a popular system and I'm interested in specifying nginx as a frontend. Apache, on the other hand, receives and gives data to Nginx, and Nginx receives and gives data to the user. Considering that I don’t really understand what the server_name parameter is for, with such an interaction it’s not clear to me how to specify it correctly, given that it is specified differently in different instructions.
nginx.org/ru/docs/http/ngx_http_core_module.html#s... in the documentation, this
server_name _ expression is
indicated twice, but its meaning is not described not only in detail, but even briefly.
If you specify the name of the site correctly, then what are the other options for, the same localhost and how to specify all sites
at once nginx.org/ru/docs/http/request_processing.html
So I read, and, given that server_name indicates the instruction for processing nginx, I still came to the conclusion that localhost should be specified, since the task of nginx is to release the apache server. And apache should apparently return localhost. Or have I misunderstood something?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question