R
R
Ruslan2021-06-15 14:18:47
Nginx
Ruslan, 2021-06-15 14:18:47

How to give access to the site only from the internal network?

The enterprise has a server on which there is a site with a purchased ip and a domain name. Everything works, no issues.

How to attach another location block or another server block to the same nginx and attach another site to it so that it can only be accessed from the internal network of the enterprise (by ip address, probably)?

I will formulate it differently:
1. There is Site1 with a white ip and with a domain name - it needs to be shown to everyone on the Internet
2. There is Site2 without a white ip and without a domain name - it needs to be shown only on the internal network
How to register this in nginx.conf blocks ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Yuriev, 2021-06-15
@dyuriev

server {
  listen 192.168.0.1:80;
  listen 192.168.0.1:443 ssl;
  server_name example.ru;
  ...
}

explicitly indicate to nginx which IP address to listen to if there are several IP addresses on the server, and not sitting behind a nat.
or
server {
  listen 80;
  listen 443 ssl;
  server_name example.ru;
  satisfy any;
  allow 192.168.0.1/24;
  allow 192.168.1.1/24;
  allow 192.168.2.100;
  deny all;
  ...
}

allow access only for certain IPs and/or subnets

V
Vladimir Korotenko, 2021-06-15
@firedragon

Just write in Google your request in English https://docs.nginx.com/nginx/admin-guide/security-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question