February 2020
Intermediate to advanced
404 pages
8h 42m
English
This is the most important piece in the Nginx setup. In this section, we will look at how to restrict access to our server using basic authentication. This is very important for our REST API servers because, suppose we have servers X, Y, and Z that can talk to each other. X can serve clients directly, but X consults Y and Z for some information by calling an internal API. We should prevent clients from accessing Y and Z. We can allow or deny IP addresses using the nginx access module. It looks like this:
location /api { ... deny 192.168.1.2; allow 192.168.1.1/24; allow 127.0.0.1; deny all;}
This configuration tells Nginx to allow requests from clients ranging 192.168.1.1/24, excluding 192.168.1.2. The next ...
Read now
Unlock full access