Skip to content

Instantly share code, notes, and snippets.

@hunzo
Created October 24, 2025 07:36
Show Gist options
  • Save hunzo/e3dd3e457207056a99a043dd81d15c9a to your computer and use it in GitHub Desktop.
Save hunzo/e3dd3e457207056a99a043dd81d15c9a to your computer and use it in GitHub Desktop.
nginx simple apikey
server {
listen 80;
server_name localhost;
location / {
default_type application/json;
if ($http_x_api_key = "") {
return 403 '{"error": "missing api key"}';
}
if ($http_x_api_key != "testkey") {
return 403 '{"error": "invalid api key"}';
}
root /usr/share/nginx/html;
index index.html index.htm;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment