mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 08:56:33 +00:00
add scripts for cdn
change aes mode to cfb in encrypt / decrypt in Security
This commit is contained in:
@@ -19,10 +19,11 @@ public static class Security
|
|||||||
if (key is not { Length: > 0 }) throw new ArgumentNullException(nameof(key));
|
if (key is not { Length: > 0 }) throw new ArgumentNullException(nameof(key));
|
||||||
|
|
||||||
using var aes = Aes.Create();
|
using var aes = Aes.Create();
|
||||||
|
aes.Mode = CipherMode.CFB;
|
||||||
aes.Key = SHA256.HashData(Encoding.UTF8.GetBytes(key));
|
aes.Key = SHA256.HashData(Encoding.UTF8.GetBytes(key));
|
||||||
aes.GenerateIV();
|
aes.GenerateIV();
|
||||||
|
|
||||||
using var encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
using var encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
||||||
|
|
||||||
await using var cs = new CryptoStream(toStream, encryptor, CryptoStreamMode.Write, leaveOpen: true);
|
await using var cs = new CryptoStream(toStream, encryptor, CryptoStreamMode.Write, leaveOpen: true);
|
||||||
|
|
||||||
// Prepend IV to the encrypted data
|
// Prepend IV to the encrypted data
|
||||||
@@ -43,8 +44,9 @@ public static class Security
|
|||||||
var iv = new byte[aes.BlockSize / 8];
|
var iv = new byte[aes.BlockSize / 8];
|
||||||
_ = await encryptedStream.ReadAsync(iv, cancellationToken);
|
_ = await encryptedStream.ReadAsync(iv, cancellationToken);
|
||||||
aes.IV = iv;
|
aes.IV = iv;
|
||||||
|
aes.Mode = CipherMode.CFB;
|
||||||
using var decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
using var decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
||||||
|
|
||||||
await using var cryptoStream = new CryptoStream(encryptedStream, decryptor, CryptoStreamMode.Read, leaveOpen: true);
|
await using var cryptoStream = new CryptoStream(encryptedStream, decryptor, CryptoStreamMode.Read, leaveOpen: true);
|
||||||
|
|
||||||
// Read and write in chunks
|
// Read and write in chunks
|
||||||
|
|||||||
+12
@@ -63,6 +63,18 @@ server {
|
|||||||
ssl_certificate /etc/letsencrypt/live/api.azaion.com/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/api.azaion.com/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/api.azaion.com/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/api.azaion.com/privkey.pem;
|
||||||
|
|
||||||
|
location /cdn/ {
|
||||||
|
alias /var/www/cdn.azaion.com/;
|
||||||
|
expires 3560d;
|
||||||
|
access_log_off;
|
||||||
|
log_not_found off;
|
||||||
|
gzip_static on;
|
||||||
|
|
||||||
|
autoindex on;
|
||||||
|
autoindex_exact_size off;
|
||||||
|
autoindex_localtime on;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://localhost:4000; # API service running on port 4000
|
proxy_pass http://localhost:4000; # API service running on port 4000
|
||||||
proxy_set_header Host \$host;
|
proxy_set_header Host \$host;
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
docker run \
|
docker run \
|
||||||
--env-file .env \
|
--env-file .env \
|
||||||
-p 4000:8080 \
|
-p 4000:8080 \
|
||||||
-v /root/content:/app/Content \
|
-v /root/api/content:/app/Content \
|
||||||
-v /root/logs:/app/logs
|
-v /root/api/logs:/app/logs
|
||||||
--name azaion.api docker.azaion.com/api
|
--name azaion.api docker.azaion.com/api
|
||||||
Vendored
+14
@@ -0,0 +1,14 @@
|
|||||||
|
mkdir -p ~/cdn/data
|
||||||
|
|
||||||
|
certbot certonly --standalone -d cdn.azaion.com
|
||||||
|
|
||||||
|
cd /etc/letsencrypt/live/cdn.azaion.com-0001 || exit
|
||||||
|
|
||||||
|
chmod -R 755 privkey.pem
|
||||||
|
ln -s privkey.pem private.key
|
||||||
|
|
||||||
|
chmod -R 755 fullchain.pem
|
||||||
|
ln -s fullchain.pem public.crt
|
||||||
|
cd ~ || exit
|
||||||
|
|
||||||
|
sh restart-minio.sh
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
MC_BINARY_PATH="/usr/local/bin/mc"
|
||||||
|
wget https://dl.min.io/client/mc/release/linux-amd64/mc -O ${MC_BINARY_PATH}
|
||||||
|
chmod +x ${MC_BINARY_PATH}
|
||||||
|
export PATH=$PATH:${MC_BINARY_PATH} >> ~/.profile
|
||||||
|
source ~/.profile
|
||||||
Vendored
+12
@@ -0,0 +1,12 @@
|
|||||||
|
mc alias set cdn http://localhost:9020 azaion-cdn-admin AzAA2onCdDmNinnn_CDN_1
|
||||||
|
|
||||||
|
mc admin user add cdn azaion-cdn-uploader AaazzA2onCuuPlonad_CerrDN_1
|
||||||
|
mc admin policy create cdn CDNUploadPolicy uploader_policy.json
|
||||||
|
mc admin policy attach cdn CDNUploadPolicy --user azaion-cdn-uploader
|
||||||
|
|
||||||
|
|
||||||
|
mc admin user add cdn azaion-cdn-user AaazzA2onCussSerrrErDN_1
|
||||||
|
mc admin policy create cdn CDNUserPolicy user_policy.json
|
||||||
|
mc admin policy attach cdn CDNUserPolicy --user azaion-cdn-user
|
||||||
|
|
||||||
|
mc mb cdn/models
|
||||||
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
docker stop minio
|
||||||
|
docker rm minio
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
-p 9020:9000 \
|
||||||
|
-p 9021:9001 \
|
||||||
|
--name minio \
|
||||||
|
-v ~/minio/data:/data \
|
||||||
|
-v /etc/letsencrypt/live/cdn.azaion.com-0001:/certs \
|
||||||
|
-e "MINIO_ROOT_USER=azaion-cdn-admin" \
|
||||||
|
-e "MINIO_ROOT_PASSWORD=AzAA2onCdDmNinnn_CDN_1" \
|
||||||
|
quay.io/minio/minio server /data \
|
||||||
|
--address ":9000" \
|
||||||
|
--console-address ":9001" \
|
||||||
|
--certs-dir /certs
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"Version": "2012-10-17",
|
||||||
|
"Statement": [
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Action": [
|
||||||
|
"s3:PutObject"
|
||||||
|
],
|
||||||
|
"Resource": ["arn:aws:s3:::models/*"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Action": [ "s3:ListBucket" ],
|
||||||
|
"Resource": [ "arn:aws:s3:::models" ]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"Version": "2012-10-17",
|
||||||
|
"Statement": [
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Action": [ "s3:GetObject" ],
|
||||||
|
"Resource": ["arn:aws:s3:::models/*"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Action": [ "s3:ListBucket" ],
|
||||||
|
"Resource": [ "arn:aws:s3:::models" ]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+6
-2
@@ -29,8 +29,12 @@ rabbitmqctl set_permissions azaion_receiver "" "" ".*"
|
|||||||
# put export PATH="$PATH:/etc/rabbitmq" to the end of the ~/.profile
|
# put export PATH="$PATH:/etc/rabbitmq" to the end of the ~/.profile
|
||||||
source ~/.profile
|
source ~/.profile
|
||||||
# 2.2 declare queues with x-queue-type stream:
|
# 2.2 declare queues with x-queue-type stream:
|
||||||
rabbitmqadmin declare queue name=azaion-annotations arguments='{"x-queue-type": "stream", "max-segment-size-bytes": 5368709118}'
|
|
||||||
rabbitmqadmin declare queue name=azaion-annotations-confirm arguments='{"x-queue-type": "stream", "max-segment-size-bytes": 5368709118}'
|
rabbitmqadmin delete queue name=azaion-annotations
|
||||||
|
rabbitmqadmin declare queue name=azaion-annotations arguments='{"x-queue-type": "stream", "max-length-bytes": 5368709120}'
|
||||||
|
rabbitmqadmin delete queue name=azaion-annotations-confirm
|
||||||
|
rabbitmqadmin declare queue name=azaion-annotations-confirm arguments='{"x-queue-type": "stream", "max-length-bytes": 5368709120}'
|
||||||
|
rabbitmqadmin delete queue name=azaion-commands
|
||||||
rabbitmqadmin declare queue name=azaion-commands
|
rabbitmqadmin declare queue name=azaion-commands
|
||||||
# 2.3 configure rabbitmq
|
# 2.3 configure rabbitmq
|
||||||
# edit /etc/rabbitmq/rabbitmq.conf
|
# edit /etc/rabbitmq/rabbitmq.conf
|
||||||
Reference in New Issue
Block a user