From 4d971ff981b12790417f3b52d67467953975f058 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 14 Jan 2024 04:33:16 +0330 Subject: [PATCH] chore(nginx): cleanup --- .../http.d/31-store-mime-types.conf.template | 2 +- .../location.d/91-json.conf.template | 163 ------------------ 2 files changed, 1 insertion(+), 164 deletions(-) delete mode 100644 packages/nginx/etc/nginx/templates/location.d/91-json.conf.template diff --git a/packages/nginx/etc/nginx/templates/http.d/31-store-mime-types.conf.template b/packages/nginx/etc/nginx/templates/http.d/31-store-mime-types.conf.template index 26e26d96..42b64161 100644 --- a/packages/nginx/etc/nginx/templates/http.d/31-store-mime-types.conf.template +++ b/packages/nginx/etc/nginx/templates/http.d/31-store-mime-types.conf.template @@ -1,3 +1,3 @@ types { - application/json asj; + application/json asj; } diff --git a/packages/nginx/etc/nginx/templates/location.d/91-json.conf.template b/packages/nginx/etc/nginx/templates/location.d/91-json.conf.template deleted file mode 100644 index 62323408..00000000 --- a/packages/nginx/etc/nginx/templates/location.d/91-json.conf.template +++ /dev/null @@ -1,163 +0,0 @@ -# Configuration environment variables -# ----------------------------------- -# $storeApiPrefix: The prefix of all nginx locations for example `/api/v1`. -# $storeRegionPublic: The location for public data. -# $storeRegionSecret: The location for secret data. -# $storeRegionAuthenticated: The location for authenticated data. -# $storeRegionManagers: The location for admin and managers data. -# $storeRegionPerUser: The location for per user data. -# $storeRegionPerDevice: The location for per device data. -# $storeRegionPerToken: The location for per token data. - - -# Variables for headers -# --------------------- -# $http_user_id: Extracted from `user-id` header. -# $http_user_token: Extracted from `user-token` header. -# $http_device_id: Extracted from `device-id` header. - -# Variables for defining locations including prefix folder -# -------------------------------------------------------- -# $user_id_location: The location of the user id. -# $user_token_location: The location of the user token. -# $device_id_location: The location of the device id. - - -# Define main routes -# ------------------ - -# Public region: Store file location that can be accessed by anyone. -location ~ ^$storeApiPrefix/$storeRegionPublic/(?.*)$ { - try_files /$storeRegionPublic/$storePath =404; -} - -# Authenticated region: Store file location that can be accessed by authenticated users. -location ~ ^$storeApiPrefix/$storeRegionAuthenticated/(?.*)$ { - if ($user_id_location = '') { - return 401; - } - - if ($http_user_token = '') { - return 401; - } - - if ($http_user_id ~ '/') { - return 400; - } - - if ($http_user_token ~ '/') { - return 400; - } - - if (!-f $document_root/$user_id_location/.token/$http_user_token.asn) { - return 403; - } - - try_files /$storeRegionAuthenticated/$storePath =404; -} - -# Managers region: Store file location that can be accessed by admin and managers only. -location ~ ^$storeApiPrefix/$storeRegionManagers/(?.*)$ { - if ($user_id_location = '') { - return 401; - } - - if ($http_user_token = '') { - return 401; - } - - if ($http_user_id ~ '/') { - return 400; - } - - if ($http_user_token ~ '/') { - return 400; - } - - if (!-f $document_root/$user_id_location/.token/$http_user_token.asn) { - return 403; - } - - if (!-f $document_root/$user_id_location/.auth/manager.asn) { - return 403; - } - - try_files /$storeRegionManagers/$storePath =404; -} - -# PerUser region: Store file location specific to each user id. Can be accessed using the user token. -location ~ ^$storeApiPrefix/$storeRegionPerUser/(?.*)$ { - if ($user_id_location = '') { - return 401; - } - - if ($http_user_token = '') { - return 401; - } - - if ($http_user_id ~ '/') { - return 400; - } - - if ($http_user_token ~ '/') { - return 400; - } - - if (!-f $document_root/$user_id_location/.token/$http_user_token.asn) { - return 403; - } - - try_files /$user_id_location/$storePath =404; -} - -# PerToken region: Store file location specific to each token. -location ~ ^$storeApiPrefix/$storeRegionPerToken/(?.*)$ { - if ($user_token_location = '') { - return 401; - } - - if ($http_user_token ~ '/') { - return 400; - } - - if (!-f /$user_token_location/token-info.doc.asj) { - return 403; - } - - try_files /$user_token_location/$storePath =404; -} - -# PerDevice region: Store file location specific to each device id. -location ~ ^$storeApiPrefix/$storeRegionPerDevice/(?.*)$ { - if ($device_id_location = '') { - return 400; - } - - if ($http_device_id ~ '/') { - return 400; - } - - if (!-f /$user_token_location/device-info.doc.asj) { - return 403; - } - - try_files /$device_id_location/$storePath =404; -} - -# Secret region: Deny secret locations -location ~ ^/$storeRegionSecret/ { - return 403; -} -location ~ ^$storeApiPrefix/$storeRegionSecret/ { - return 403; -} - -location = /debug-info-110 { - default_type application/json; - return 200 '{"storeApiPrefix": "$storeApiPrefix", "storeRegionPublic": "$storeRegionPublic", "storeRegionSecret": "$storeRegionSecret", "storeRegionAuthenticated": "$storeRegionAuthenticated", "storeRegionManagers": "$storeRegionManagers", "storeRegionPerUser": "$storeRegionPerUser", "storeRegionPerDevice": "$storeRegionPerDevice", "storeRegionPerToken": "$storeRegionPerToken", "user_id_location": "$user_id_location", "user_token_location": "$user_token_location", "device_id_location": "$device_id_location", "http_user_id": "$http_user_id", "http_user_token": "$http_user_token", "http_device_id": "$http_device_id", "document_root": "$document_root", "uri": "$uri", "request_uri": "$request_uri", "request_method": "$request_method", "args": "$args", "query_string": "$query_string", "request_body": "$request_body", "remote_addr": "$remote_addr", "remote_port": "$remote_port", "remote_user": "$remote_user", "http_referer": "$http_referer", "http_user_agent": "$http_user_agent", "http_x_forwarded_for": "$http_x_forwarded_for"}'; -} - -# Deny all unknown location -location / { - internal; -}