Answer the question
In order to leave comments, you need to log in
Prohibition of accessing the site by the IP address of the server (only by domain), how to implement?
Good day to all. I'm not very good at setting up the server, I spend a lot of time digging in Google, but I did not find the right solution for my problem. The essence of the problem:
- The site is located on a VPS (IP dedicated, without neighbors).
- A site visitor can access it by IP: xx.xx.xx.xx by typing in the address bar of the browser, or by the domain.ru domain
- How to block access to the site using the IP address using Htaccess, NGNIX configuration or something else , allow only on a specific domain?
Googled and found only a way to redirect from IP to www domain through .htaccess, but I didn’t find the ban that I need. I hope for your help.
Answer the question
In order to leave comments, you need to log in
Make virtual hosts. Make the virtual host with an empty site the default, and the virtual host with the domain is the one you need.
Thus, for any domain name that leads to your IP, the user will see an empty site (well, or with a warning), and for a normal domain - a normal site.
Look up information on nginx hosting multiple sites on the same host.
Based on your config, everything that comes to port 80 is sent to the site.
Nginx and two sites on the same domain
informatikum.ru/linux/138-neskolko-domenov-na-one...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question