Created
October 24, 2025 07:36
-
-
Save hunzo/e3dd3e457207056a99a043dd81d15c9a to your computer and use it in GitHub Desktop.
nginx simple apikey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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