-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nginx): accelerated nginx server (#139)
- Loading branch information
Showing
6 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
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. |
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
packages/nginx/etc/nginx/templates/http.d/49-map-bearer-token.conf.template
This file contains 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
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 ''; | ||
} |
8 changes: 0 additions & 8 deletions
8
packages/nginx/etc/nginx/templates/location.d/10-error-page.conf.template
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/nginx/etc/nginx/templates/location.d/90-home-json.conf.template
This file contains 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
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 ::.."}'; | ||
} |
47 changes: 47 additions & 0 deletions
47
packages/nginx/etc/nginx/templates/location.d/91-json.conf.template
This file contains 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
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; | ||
} |