Merge branch 'installation' into 'develop'
Installation See merge request soapbox-pub/ditto!40
This commit is contained in:
commit
6382f98a5e
|
@ -0,0 +1,82 @@
|
|||
# Nginx configuration for Ditto with IPFS.
|
||||
#
|
||||
# Edit this file to change occurences of "example.com" to your own domain.
|
||||
|
||||
upstream ditto {
|
||||
server 127.0.0.1:8000;
|
||||
}
|
||||
|
||||
upstream ipfs_gateway {
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
location /.well-known/acme-challenge/ { allow all; }
|
||||
location / { return 301 https://$host$request_uri; }
|
||||
}
|
||||
|
||||
server {
|
||||
# Uncomment these lines once you acquire a certificate:
|
||||
# listen 443 ssl http2;
|
||||
# listen [::]:443 ssl http2;
|
||||
server_name example.com;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# Uncomment these lines once you acquire a certificate:
|
||||
# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
|
||||
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
|
||||
|
||||
keepalive_timeout 70;
|
||||
sendfile on;
|
||||
client_max_body_size 100m;
|
||||
ignore_invalid_headers off;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
location / {
|
||||
proxy_pass http://ditto;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
# Uncomment these lines once you acquire a certificate:
|
||||
# listen 443 ssl http2;
|
||||
# listen [::]:443 ssl http2;
|
||||
server_name media.example.com;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# Uncomment these lines once you acquire a certificate:
|
||||
# ssl_certificate /etc/letsencrypt/live/media.example.com/fullchain.pem;
|
||||
# ssl_certificate_key /etc/letsencrypt/live/media.example.com/privkey.pem;
|
||||
|
||||
keepalive_timeout 70;
|
||||
sendfile on;
|
||||
client_max_body_size 1m;
|
||||
ignore_invalid_headers off;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
location / {
|
||||
proxy_pass http://ipfs_gateway;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Ditto
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=ditto
|
||||
WorkingDirectory=/opt/ditto
|
||||
ExecStart=/usr/local/bin/deno task start
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=IPFS Daemon
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=ditto
|
||||
ExecStart=/usr/local/bin/ipfs daemon
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -3,8 +3,6 @@ import { IpfsHash, S3Client } from '@/deps.ts';
|
|||
|
||||
import type { Uploader } from './types.ts';
|
||||
|
||||
const s3 = new S3Client({ ...Conf.s3 });
|
||||
|
||||
/**
|
||||
* S3-compatible uploader for AWS, Wasabi, DigitalOcean Spaces, and more.
|
||||
* Files are named by their IPFS CID and exposed at `/ipfs/<cid>`, letting it
|
||||
|
@ -14,7 +12,7 @@ const s3Uploader: Uploader = {
|
|||
async upload(file) {
|
||||
const cid = await IpfsHash.of(file.stream()) as string;
|
||||
|
||||
await s3.putObject(`ipfs/${cid}`, file.stream(), {
|
||||
await client().putObject(`ipfs/${cid}`, file.stream(), {
|
||||
metadata: {
|
||||
'Content-Type': file.type,
|
||||
'x-amz-acl': 'public-read',
|
||||
|
@ -26,8 +24,13 @@ const s3Uploader: Uploader = {
|
|||
};
|
||||
},
|
||||
async delete(cid) {
|
||||
await s3.deleteObject(`ipfs/${cid}`);
|
||||
await client().deleteObject(`ipfs/${cid}`);
|
||||
},
|
||||
};
|
||||
|
||||
/** Build S3 client from config. */
|
||||
function client() {
|
||||
return new S3Client({ ...Conf.s3 });
|
||||
}
|
||||
|
||||
export { s3Uploader };
|
||||
|
|
Loading…
Reference in New Issue