>_ IzzyLab

Hands-on task

This task is step 11 of the course “nginx basics”

Lock Down the Internal Section

medium~12 min

The site (nginx, port 80) has an internal section /internal/. Lock it down: any request there must get 403 Forbidden, while the rest of the site stays open (200).

What you'll practise:
  • nginx
  • location
  • return
  • 403 forbidden
  • access control

Topic breakdown

nginx applies to a request the rules from the matching location, chosen by URL; to close only one prefix without touching the rest of the site, you set up a separate block for it. You can instantly return the forbidden status with the return directive (it halts processing without looking at files) — the right code comes from the task. An alternative is address-based access control via deny/allow. Other requests don't fall under this location, so they keep being served as usual. After editing, the config is checked and reread.

What's checked

  1. /internal/ returns 403
  2. home page returns 200

What it looks like