Skip to content

Commit

Permalink
feat(nginx): accelerated nginx server
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD committed Nov 26, 2023
1 parent fb32869 commit 823dc07
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Alwatr Storage

An extremely fast and compact json-based database with memory cache.
This is an extremely fast and compact JSON-based database that operates in memory, includes a JSON file backup, and serve over the highly accelerated Nginx.
9 changes: 0 additions & 9 deletions packages/nginx/data/error.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
map $http_authorization $bearer_token {
~*^Bearer\s+(?<token>\S+)$ $token;
default '';
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
location = / {
# return static json for home page
default_type application/json;
return 200 '{"ok": true, "data": "..:: Alwatr Accelerated Storage Server ::.."}';
return 200 '{"ok": true, "data": "..:: Alwatr Storage Server ::.."}';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Serves all data for public users without requiring any token.
# If data is not found, it returns a 200 status code with `data: null`.
location ~ ^(/api)?/v\d+/publistore/hub/(?<doc_path>.*)$ {
try_files /publistore/hub/$doc_path.json @null_data;
}

# If data is not found, it returns a 200 status code with `data: null`.
location ~ ^(/api)?/v\d+/publistore/vault/(?<doc_path>.*)$ {
if ($bearer_token = "") {
return 401;
}
if (!-d $document_root/publistore/auth/$bearer_token) {
return 403;
}

try_files /publistore/vault/$doc_path.json @null_data;
}

# Serves private data that varies for each authenticated user who provides a valid bearer token.
# If data is not found, it returns a 200 status code with `data: null`.
location ~ ^(/api)?/v\d+/publistore/auth/(?<doc_path>.*)$ {
location ~ ^/auth/(?<doc_path>.*)$ {
if ($bearer_token = "") {
return 401;
}
if (!-d $document_root/publistore/auth/$bearer_token) {
return 403;
}

try_files /publistore/auth/$bearer_token/$doc_path.json @null_data;
}
}

location @null_data {
default_type application/json;
return 200 '{"ok": true, "data": null}';
}

# Deny locations containing /securage/
location ~ /securage/ {
return 403;
}

# Deny all unknown location
location / {
deny all;
}

0 comments on commit 823dc07

Please sign in to comment.