07887 423199me@richieaubin.com

Protect staging and private pages

A page is private when unauthorised visitors cannot read it. Search directives can help manage discovery or indexing of public material, but access controls protect the content itself.

Staging access controls example
Example image · CC0 1.0 licence

Choose a way to do this check

Private browser session

  1. Open the staging page and a direct file URL without authentication.
  2. Check status and content, then confirm the allowed route in a fresh authorised session.

Hosting access control

  1. Use the approved access mechanism for the host, origin and storage route.
  2. Confirm intended access and cache behaviour separately for authenticated and anonymous visitors.

Read the response

  1. Paste anonymous response headers without credentials or cookies.
  2. Check the status and any authentication or redirect header. Make sure the protected body was not returned.

1. List all the ways the content can be reached

Check staging hostnames, preview URLs, static assets, downloadable files and storage endpoints. Protect the content at the layer that actually serves it. Locking the main HTML page does not protect a PDF hosted at a separate public URL. Record each endpoint and the team responsible for it.

For environments with private or sensitive data, use your organisation's approved identity provider, network controls or application authorisation. Avoid copying real customer records into staging where possible. Keep any local diagnostic data inside the approved environment.

2. Apply access controls before exposing the environment

Basic authentication over HTTPS can be a simple gate for a limited staging site where your policy allows it. Apply it to the existing staging server block, confirm the password file is outside the public root and follow your credential management process. Use TLS because Basic credentials are not independently encrypted.

Nginx · existing HTTPS staging server block
auth_basic "Staging";
auth_basic_user_file /etc/nginx/staging.htpasswd;

Review child locations and any proxy or static-file routes for overrides. Check the origin or storage permissions where relevant so a separate public hostname does not expose the same files. Avoid sharing the password file or putting credentials in build artefacts.

3. Test anonymous and authorised requests

Use a fresh request without cookies or credentials. The staging URL should return the expected denial or redirect to the authorised identity flow. Also request one asset that should be protected. A 200 login form can be appropriate at the login endpoint, but it should never contain the protected content.

Terminal · inspect unauthenticated staging responses
host='https://staging.example.com'
for path in / /preview/report.pdf; do
  curl -sS -D - -o /dev/null "$host$path" | grep -Ei '^(HTTP/|www-authenticate:|location:)'
done

Then test with an approved account in a fresh browser session. Verify the required pages and files still work. Check that caching does not expose an authorised response to a later anonymous request. Keep production and staging settings separate and test an unaffected public production URL if they share configuration.

Protect the material first. If a URL still appears in search, use the relevant search engine's removal tools where appropriate, then track its long-term state separately. Remove accidental public links and sitemap entries. If access controls break legitimate internal testing, restore the previous approved control or narrow the scope without reopening private pages to public requests.

Technical references

Frequently asked questions

Is robots.txt enough for a staging site?

No. It does not stop a browser or other client reading an accessible URL.

Does noindex protect the content itself?

No. It asks supporting search engines to exclude the page from their index.

Where should I put the password file?

Outside the web root, with permissions appropriate for the server and your credential process.

Should I test a staging PDF separately?

Yes. It may be served by a different location, storage endpoint or cache policy.

Written by Richie Aubin

Published