Now the site is available on external ip: http://12.34.56.78
2 answers
for example, create a “stub”:
server { listen 80; server_name 12.34.56.78; # какие-то директивы } which, for example, will redirect to the desired domain name:
return 301 http://доменное.имя$request_uri; (instead of the line # какие-то директивы ).
- A redirect in a stub is not an obvious thing, it can lead to the maintenance of someone else's traffic, for example (a foreign domain is registered in the DNS with the IP of our web server). - raciasolvo
- @raciasolvo, the proposed "stub" will process requests in which the
hostheader contains the specified ip-address . if the foreign domain refers to this ip-address, then when an http-request to this foreign domain in thehostheader is he, and not the ip-address, that is, the proposed "stub" does not "work", contrary to your concerns. - aleksandr barakin - You are right, everything that tries to gain access by IP gets into the stub. For the case I have described, I will need another, but another stub. I did not correctly give an example to the problem - is it necessary to redirect other people's traffic? Can it be safer to put
return 444instead of a redirect? When I received a new IP, I came across a situation where third-party, not-so-good traffic goes exactly over IP. Although, probably, it is a question of each specific situation. And traffic may not be alien. The answer is a plus. - raciasolvo
|
If you use the default settings, all requests are processed by a single server section, which is valid for any domain name or address.
This is what a “universal” server looks like and should not be like this :) That is, this is not what you want. Replace _ with the domain name you need.
server_name _; |
hostwill the domain name appear. - aleksandr barakin