M
M
Minorus_one2021-03-04 09:19:24
Apache HTTP Server
Minorus_one, 2021-03-04 09:19:24

How to implement a ban on the site through IP and port, and leave access only by domain name?

Good day. There is a server on which Apache is twisted. The server has a white static IP. There are a number of applications with a web face. They are accessed by IP-address:port. For convenience, I received a domain name. In apache, I set up virtual hosts with proxying to the required port so that the link looks like torrent.mydomen.ru, which leads to 1.1.1.1:9091 (IP in this case is used as an example).
Now the question is how to implement a ban on the site through IP and port, and leave access only by domain name?

PS Another NextCloud is running on the server. There, I was able to block access by IP using a virtual server in which ServerName contains my IP and the site leads to a stub. I would like everything that spins on the ports to lead to this stub when entering the IP address and port.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2021-03-04
@shambler81

All
sites simply cannot lie by default on ports other than 80 and 443, otherwise you will always have to append the port, but this does not happen.
and you won't get enough white IPs for all sites.
And on the TCP \ IP stack, you need to either open another port for a new site or another IP, there is no third way (except how to wind up crutches).
Actually, the Web server makes a crutch so that you can push the unimaginable
, it parses your browser's http_referer, parses the host line in it and substitutes your site config with its paths and variables on the basis of it
, so you can hang several sites on one port and start the web server.
However, where is your problem.
And while
1. your site is in the /var/www folder and it is the only one
2. when you install the web server, you automatically create the first config in which the site name is missing or something like that - that is, any in general, including ip, it's done for simplicity of the first start, cheap and cheerful and immediately works.
For good, this config should lead to index.html - hello, you got to the server, but something went wrong with your domain, I didn’t find it.
And all other sites must have an explicitly specified domain.

....
 ServerName 3dpaneli.ru
 ServerAlias www.3dpaneli.ru
...

In short, you need to explicitly specify the name server, or even better, create a second config.
That is, you are not allowed to access by IP, you are allowed to access by any entry that will lead to this server.
Configs may differ slightly from the selected web view panel, php, nginx, etc.
on it I do not result all config but only the part necessary to you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question