Ինչպես տեղադրել CryptPad համագործակցային գրասենյակային փաթեթը Ubuntu 22.04-ում


Այս էջում

  1. Նախադրյալներ
  2. Քայլ 1 - Կարգավորել Firewall-ը
  3. Քայլ 2 - Տեղադրեք Git-ը
  4. Քայլ 3 - Տեղադրեք Nodejs-ը
  5. Քայլ 4 - Տեղադրեք Bower
  6. Քայլ 5 - Տեղադրեք Cryptpad-ը
  7. Քայլ 6 - Կարգավորեք Cryptpad-ը
  8. Քայլ 7 - Տեղադրեք Nginx
  9. Քայլ 8 - Տեղադրեք SSL-ը
  10. Քայլ 9 - Կարգավորեք Nginx-ը
  11. Քայլ 10 - Ստեղծեք Cryptpad Systemd ծառայություն
  12. Քայլ 11 - Մուտք գործեք և կազմաձևեք Cryptpad-ը
  13. Քայլ 12 - Թարմացրեք Cryptpad-ը
  14. Եզրակացություն

Cryptpad-ը բաց կոդով համատեղ գրասենյակային փաթեթ է, որն այլընտրանք է Office 365-ին: Այն թույլ է տալիս մուտք գործել գրասենյակային հավելվածներ վեբ բրաուզերի միջոցով: Cryptpad-ի և Office 365-ի միջև տարբերությունն այն է, որ Cryptpad-ը ծայրից ծայր կոդավորված է, ինչը նշանակում է, որ դուք կարող եք ստեղծել և կիսվել փաստաթղթերով ուրիշների հետ՝ առանց անձնական տվյալների արտահոսքի ռիսկի: Cryptpad-ով առաջարկվող հավելվածները ներառում են Rich Text, Spreadsheets, Code/Markdown, Kanban, Slides, Whiteboards և Forms:

Այս ձեռնարկում դուք կսովորեք, թե ինչպես տեղադրել Cryptpad փաթեթը Ubuntu 22.04 սերվերի վրա:

Նախադրյալներ

    Ubuntu 22.04-ով աշխատող սերվեր՝ նվազագույնը 2 ԳԲ օպերատիվ հիշողությամբ և 2 պրոցեսորի միջուկով:

    Ոչ արմատային օգտատեր՝ sudo արտոնություններով:

    Երկու լիովին որակավորված տիրույթի անուններ (FQDN), ինչպիսիք են example.com և docs.example.com:

    Համոզվեք, որ ամեն ինչ թարմացվում է:

    $ sudo apt update
    $ sudo apt upgrade
    

    Մի քանի փաթեթներ, որոնք անհրաժեշտ են ձեր համակարգին:

    $ sudo apt install wget curl nano software-properties-common dirmngr apt-transport-https gnupg2 ca-certificates lsb-release ubuntu-keyring unzip -y
    

    Այս փաթեթներից որոշները կարող են արդեն տեղադրված լինել ձեր համակարգում:

Քայլ 1 - Կարգավորել Firewall-ը

Առաջին քայլը firewall-ի կազմաձևումն է: Ubuntu-ն լռելյայն գալիս է ufw-ով (Uncomplicated Firewall):

Ստուգեք, արդյոք firewall-ը աշխատում է:

$ sudo ufw status

Դուք պետք է ստանաք հետևյալ արդյունքը.

Status: inactive

Թույլատրել SSH միացքը, որպեսզի այն միացնելուց հետո firewall-ը չխախտի ընթացիկ կապը:

$ sudo ufw allow OpenSSH

Թույլատրել նաև HTTP և HTTPS պորտերը:

$ sudo ufw allow http
$ sudo ufw allow https

Միացնել Firewall-ը

$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

Կրկին ստուգեք firewall-ի կարգավիճակը:

$ sudo ufw status

Դուք պետք է տեսնեք նմանատիպ արդյունք:

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
443                        ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)

Քայլ 2 - Տեղադրեք Git-ը

Git-ը սովորաբար նախապես տեղադրված է Ubuntu 22.04-ի հետ, բայց եթե այն տեղադրված չէ, գործարկեք հետևյալ հրամանը՝ այն տեղադրելու համար:

$ sudo apt install git -y

Ստուգեք Git-ի տարբերակը:

$ git --version
git version 2.34.1

Գործարկեք հետևյալ հրամանները՝ Git-ը կարգավորելու համար, որպեսզի դրան ավելացնեք ձեր անունը և էլփոստի հասցեն:

git config --global user.name "Your Name"
git config --global user.email "[email "

Քայլ 3 - Տեղադրեք Nodejs-ը

Nodejs-ը տեղադրելու համար մենք կօգտագործենք Node Version Manager-ը (NVM): Տեղադրեք NVM սկրիպտը՝ օգտագործելով հետևյալ հրամանը.

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

Դուք կարող եք ստանալ NVM-ի վերջին տարբերակը նրա GitHub պահոցից:

Այն օգտագործելու համար դուք պետք է սկզբնավորեք ձեր .bashrc ֆայլը:

$ source ~/.bashrc

Ստուգեք Node-ի հասանելի տարբերակների ցանկը:

$ nvm list-remote

Դուք կստանաք նմանատիպ արդյունք:

.....
        v18.9.0
        v18.9.1
       v18.10.0
       v18.11.0
       v18.12.0   (LTS: Hydrogen)
       v18.12.1   (LTS: Hydrogen)
       v18.13.0   (LTS: Hydrogen)
       v18.14.0   (LTS: Hydrogen)
->     v18.14.1   (Latest LTS: Hydrogen)
        v19.0.0
        v19.0.1
        v19.1.0
        v19.2.0
        v19.3.0
        v19.4.0
        v19.5.0
        v19.6.0
        v19.6.1

Տեղադրեք Node-ի վերջին LTS տարբերակը (v18.x կամ) այս ձեռնարկը գրելու պահին:

$ nvm install lts/hydrogen

Ստուգեք տեղադրումը:

$ node -v
v18.14.1

Քայլ 4 - Տեղադրեք Bower

Bower-ը փաթեթի կառավարիչ է Cryptpad-ի կողմից օգտագործվող ճակատային բաղադրիչների համար: Տեղադրեք այն՝ օգտագործելով հետևյալ հրամանը.

$ npm install -g bower

Քայլ 5 - Տեղադրեք Cryptpad-ը

Կլոնավորեք Cryptpad GitHub պահոցը:

$ git clone https://github.com/xwiki-labs/cryptpad.git cryptpad

Անցեք գրացուցակին:

$ cd cryptpad

Անցեք պահեստը վերջին տարբերակին:

$ git checkout $(git tag -l | grep -v 'v1.*$' | sort -V | tail -n 1)

Տեղադրեք Cryptpad-ը՝ օգտագործելով հետևյալ հրամանները.

$ npm install
$ bower install

Կառուցեք Cryptpad ստատիկ էջեր և միացրեք սոցիալական մեդիայի հղումների նախադիտումները՝ օգտագործելով հետևյալ հրամանը.

$ npm run build

Քայլ 6 - Կարգավորեք Cryptpad-ը

Ստեղծեք կազմաձևման ֆայլը՝ օգտագործելով տրված օրինակ ֆայլը:

$ cp /home/$USER/cryptpad/config/config.example.js /home/$USER/cryptpad/config/config.js

Բացեք կազմաձևման ֆայլը խմբագրման համար:

$ nano ~/cryptpad/config/config.js

Գտեք httpUnsafeOrigin՝ 'http://localhost:3000', տողը և փոխեք դրա արժեքը ձեր հիմնական տիրույթում:

httpUnsafeOrigin: 'https://example.com',

Գտեք // httpSafeOrigin. «https://some-other-domain.xyz» տողը և ապամեկնաբանեք այն՝ հեռացնելով դրա դիմացի կտրվածքի նշանները և փոխեք դրա արժեքը ձեր ենթադոմեյնի:

httpSafeOrigin: "https://docs.example.com",

Ավելացրեք հետևյալ տողը httpSafeOrigin փոփոխականի անմիջապես տակ:

httpSafeOrigin: "https://docs.example.com",
    adminEmail: "[email ",

Պահպանեք ֆայլը՝ սեղմելով Ctrl + X և մուտքագրելով Y, երբ հուշում է ավարտելուց հետո:

Հետագա կազմաձևման համար ստեղծեք ~/cryptpad/customize.dist/application_config.js պատճենը ~/cryptpad/customize գրացուցակում:

$ cp ~/cryptpad/customize.dist/application_config.js ~/cryptpad/customize

Բացեք ~/cryptpad/customize/application_config.js ֆայլը խմբագրման համար:

$ nano ~/cryptpad/customize/application_config.js

Համոզվեք, որ ավելացրեք բոլոր կոնֆիգուրացիաները return AppConfig; տողից առաջ:

Cryptpad-ի չգրանցված օգտագործումն անջատելու համար ավելացրեք հետևյալ տողը.

AppConfig.registeredOnlyTypes = AppConfig.availablePadTypes;

Հղումներ ավելացրեք Գաղտնիության քաղաքականության, Ծառայությունների մատուցման պայմանների և Imprint էջերին:

// Privacy Policy
AppConfig.privacy = 'https://example.com/privacy-policy/';
// Terms of Service
AppConfig.terms = 'https://example.com/terms-of-service/';
// Imprint / Legal Notice
AppConfig.imprint = 'https://example.com/imprint/';

Ավելացրեք գաղտնաբառի աղ՝ Cryptpad-ն ապահովելու համար:

AppConfig.loginSalt = 'ggkljerthhkletho0the90hoserhtgse90rh4ohzisdofh90-43kbdf9009io';

Գաղտնաբառի նվազագույն երկարությունը մեծացնելու համար ավելացրեք հետևյալ տողը.

AppConfig.minimumPasswordLength = 10;

Պահպանեք ֆայլը՝ սեղմելով Ctrl + X և մուտքագրելով Y, երբ հուշում է ավարտելուց հետո: Նախքան Cryptpad-ը սկսելը, մենք նախ պետք է տեղադրենք Nginx-ը, ստեղծենք SSL վկայագիր և կարգավորենք Nginx սերվերը՝ Cryptpad-ի տիրույթները մուտքի համար պատրաստելու համար:

Քայլ 7 - Տեղադրեք Nginx

Ubuntu 22.04-ը մատակարարվում է Nginx-ի ավելի հին տարբերակով: Վերջին տարբերակը տեղադրելու համար անհրաժեշտ է ներբեռնել պաշտոնական Nginx պահոցը:

Ներմուծեք Nginx-ի ստորագրման բանալին:

$ curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
	| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

Ավելացրեք պահեստը Nginx-ի կայուն տարբերակի համար:

$ echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg arch=amd64] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

Թարմացրեք համակարգի պահեստները:

$ sudo apt update

Տեղադրեք Nginx-ը:

$ sudo apt install nginx

Ստուգեք տեղադրումը:

$ nginx -v
nginx version: nginx/1.22.1

Գործարկեք Nginx սերվերը:

$ sudo systemctl start nginx

Քայլ 8 - Տեղադրեք SSL-ը

SSL վկայագիր ստեղծելու համար մենք պետք է տեղադրենք Certbot-ը: Կարող եք կա՛մ տեղադրել Certbot-ը՝ օգտագործելով Ubuntu-ի պահոցը, կա՛մ ձեռք բերել վերջին տարբերակը՝ օգտագործելով Snapd գործիքը: Մենք կօգտագործենք Snapd տարբերակը:

Ubuntu 22.04-ը գալիս է լռելյայն տեղադրված Snapd-ով: Գործարկեք հետևյալ հրամանները՝ համոզվելու համար, որ Snapd-ի ձեր տարբերակը արդիական է: Համոզվեք, որ Snapd-ի ձեր տարբերակը արդիական է:

$ sudo snap install core
$ sudo snap refresh core

Տեղադրեք Certbot-ը:

$ sudo snap install --classic certbot

Օգտագործեք հետևյալ հրամանը՝ համոզվելու համար, որ Certbot հրամանն աշխատում է՝ ստեղծելով խորհրդանշական հղում դեպի /usr/bin գրացուցակը:

$ sudo ln -s /snap/bin/certbot /usr/bin/certbot

Գործարկեք հետևյալ հրամանը՝ SSL վկայական ստեղծելու համար:

$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email  -d example.com -d docs.example.com

Վերոնշյալ հրամանը վկայական կներբեռնի ձեր սերվերի /etc/letsencrypt/live/example.com գրացուցակում example.com և docs տիրույթների համար: example.com:

Ստեղծեք Diffie-Hellman խումբ վկայագիր:

$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096

Ստուգելու համար, թե արդյոք SSL-ի նորացումը լավ է աշխատում, կատարեք գործընթացը չոր:

$ sudo certbot renew --dry-run

Եթե սխալներ չկան, ապա ամեն ինչ պատրաստ է: Ձեր վկայականը ինքնաբերաբար կերկարաձգվի:

Քայլ 9 - Կարգավորեք Nginx-ը

Բացեք ֆայլը /etc/nginx/nginx.conf խմբագրման համար:

$ sudo nano /etc/nginx/nginx.conf

Ավելացրեք հետևյալ տողը include /etc/nginx/conf.d/*.conf; տողից առաջ:

server_names_hash_bucket_size  64;

Պահպանեք ֆայլը՝ սեղմելով Ctrl + X և մուտքագրելով Y, երբ պահանջվում է:

Ստեղծեք և բացեք ֆայլը /etc/nginx/conf.d/cryptpad.conf խմբագրման համար:

$ sudo nano /etc/nginx/conf.d/cryptpad.conf

Դրա մեջ տեղադրեք հետևյալ կոդը.

server {
    # Redirect any http requests to https
    listen 80;
    listen [::]:80;
    server_name example.com docs.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    # CryptPad serves static assets over these two domains.
    # `main_domain` is what users will enter in their address bar.
    # Privileged computation such as key management is handled in this scope
    # UI content is loaded via the `sandbox_domain`.
    # "Content Security Policy" headers prevent content loaded via the sandbox
    # from accessing privileged information.
    # These variables must be different to take advantage of CryptPad's sandboxing techniques.
    # In the event of an XSS vulnerability in CryptPad's front-end code
    # this will limit the amount of information accessible to attackers.
    set $main_domain "example.com";
    set $sandbox_domain "docs.example.com";

    # By default CryptPad allows remote domains to embed CryptPad documents in iframes.
    # This behaviour can be blocked by changing $allowed_origins from "*" to the
    # sandbox domain, which must be permitted to load content from the main domain
    # in order for CryptPad to work as expected.
    #
    # An example is given below which can be uncommented if you want to block
    # remote sites from including content from your server
    set $allowed_origins "*";
    # set $allowed_origins "https://${sandbox_domain}";

    # CryptPad's dynamic content (websocket traffic and encrypted blobs)
    # can be served over separate domains. Using dedicated domains (or subdomains)
    # for these purposes allows you to move them to a separate machine at a later date
    # if you find that a single machine cannot handle all of your users.
    # If you don't use dedicated domains, this can be the same as $main_domain
    # If you do, they can be added as exceptions to any rules which block connections to remote domains.
    # You can find these variables referenced below in the relevant places
    set $api_domain "example.com";
    set $files_domain "example.com";

    # nginx doesn't let you set server_name via variables, so you need to hardcode your domains here
    server_name example.com docs.example.com;

    # You'll need to Set the path to your certificates and keys here
    # IMPORTANT: this config is intended to serve assets for at least two domains
    # (your main domain and your sandbox domain). As such, you'll need to generate a single SSL certificate
    # that includes both domains in order for things to work as expected.
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;

    # diffie-hellman parameters are used to negotiate keys for your session
    # generate strong parameters using the following command
    ssl_dhparam /etc/ssl/certs/dhparam.pem;

    # Speeds things up a little bit when resuming a session
    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;
    ssl_session_tickets off;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers off;

    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;

    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8 8.8.4.4 valid=300s;
    resolver_timeout 5s;

    # verify chain of trust of OCSP response using Root CA and Intermediate certs
    ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;

    # replace with the IP address of your resolver
    resolver 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 9.9.9.9 149.112.112.112 208.67.222.222 208.67.220.220;

    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options nosniff;
    add_header Access-Control-Allow-Origin "${allowed_origins}";
    # add_header X-Frame-Options "SAMEORIGIN";

    # Opt out of Google's FLoC Network
    add_header Permissions-Policy interest-cohort=();

    # Enable SharedArrayBuffer in Firefox (for .xlsx export)
    add_header Cross-Origin-Resource-Policy cross-origin;
    add_header Cross-Origin-Embedder-Policy require-corp;

    # Insert the path to your CryptPad repository root here
    root /home/username/cryptpad;
    index index.html;
    error_page 404 /customize.dist/404.html;

    # any static assets loaded with "ver=" in their URL will be cached for a year
    if ($args ~ ver=) {
        set $cacheControl max-age=31536000;
    }
    # This rule overrides the above caching directive and makes things somewhat less efficient.
    # We had inverted them as an optimization, but Safari 16 introduced a bug that interpreted
    # some important headers incorrectly when loading these files from cache.
    # This is why we can't have nice things :(
    if ($uri ~ ^(\/|.*\/|.*\.html)$) {
        set $cacheControl no-cache;
    }

    # Will not set any header if it is emptystring
    add_header Cache-Control $cacheControl;

    # CSS can be dynamically set inline, loaded from the same domain, or from $main_domain
    set $styleSrc   "'unsafe-inline' 'self' https://${main_domain}";

    # connect-src restricts URLs which can be loaded using script interfaces
    # if you have configured your instance to use a dedicated $files_domain or $api_domain
    # you will need to add them below as: https://${files_domain} and https://${api_domain}
    set $connectSrc "'self' https://${main_domain} blob: wss://${api_domain} https://${sandbox_domain}";

    # fonts can be loaded from data-URLs or the main domain
    set $fontSrc    "'self' data: https://${main_domain}";

    # images can be loaded from anywhere, though we'd like to deprecate this as it allows the use of images for tracking
    set $imgSrc     "'self' data: blob: https://${main_domain}";

    # frame-src specifies valid sources for nested browsing contexts.
    # this prevents loading any iframes from anywhere other than the sandbox domain
    set $frameSrc   "'self' https://${sandbox_domain} blob:";

    # specifies valid sources for loading media using video or audio
    set $mediaSrc   "blob:";

    # defines valid sources for webworkers and nested browser contexts
    # deprecated in favour of worker-src and frame-src
    set $childSrc   "https://${main_domain}";

    # specifies valid sources for Worker, SharedWorker, or ServiceWorker scripts.
    # supercedes child-src but is unfortunately not yet universally supported.
    set $workerSrc  "'self'";

    # script-src specifies valid sources for javascript, including inline handlers
    set $scriptSrc  "'self' resource: https://${main_domain}";

    # frame-ancestors specifies which origins can embed your CryptPad instance
    # this must include 'self' and your main domain (over HTTPS) in order for CryptPad to work
    # if you have enabled remote embedding via the admin panel then this must be more permissive.
    # note: cryptpad.fr permits web pages served via https: and vector: (element desktop app)
    set $frameAncestors "'self' https://${main_domain}";
    # set $frameAncestors "'self' https: vector:";

    set $unsafe 0;
    # the following assets are loaded via the sandbox domain
    # they unfortunately still require exceptions to the sandboxing to work correctly.
    if ($uri ~ ^\/(sheet|doc|presentation)\/inner.html.*$) { set $unsafe 1; }
    if ($uri ~ ^\/common\/onlyoffice\/.*\/.*\.html.*$) { set $unsafe 1; }

    # everything except the sandbox domain is a privileged scope, as they might be used to handle keys
    if ($host != $sandbox_domain) { set $unsafe 0; }
    # this iframe is an exception. Office file formats are converted outside of the sandboxed scope
    # because of bugs in Chromium-based browsers that incorrectly ignore headers that are supposed to enable
    # the use of some modern APIs that we require when javascript is run in a cross-origin context.
    # We've applied other sandboxing techniques to mitigate the risk of running WebAssembly in this privileged scope
    if ($uri ~ ^\/unsafeiframe\/inner\.html.*$) { set $unsafe 1; }

    # privileged contexts allow a few more rights than unprivileged contexts, though limits are still applied
    if ($unsafe) {
        set $scriptSrc "'self' 'unsafe-eval' 'unsafe-inline' resource: https://${main_domain}";
    }

    # Finally, set all the rules you composed above.
    add_header Content-Security-Policy "default-src 'none'; child-src $childSrc; worker-src $workerSrc; media-src $mediaSrc; style-src $styleSrc; script-src $scriptSrc; connect-src $connectSrc; font-src $fontSrc; img-src $imgSrc; frame-src $frameSrc; frame-ancestors $frameAncestors";

    # The nodejs process can handle all traffic whether accessed over websocket or as static assets
    # We prefer to serve static content from nginx directly and to leave the API server to handle
    # the dynamic content that only it can manage. This is primarily an optimization
    location ^~ /cryptpad_websocket {
        proxy_pass http://localhost:3000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # WebSocket support (nginx 1.4)
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
    }

    location ^~ /customize.dist/ {
        # This is needed in order to prevent infinite recursion between /customize/ and the root
    }
    # try to load customizeable content via /customize/ and fall back to the default content
    # located at /customize.dist/
    # This is what allows you to override behaviour.
    location ^~ /customize/ {
        rewrite ^/customize/(.*)$ $1 break;
        try_files /customize/$uri /customize.dist/$uri;
    }

    # /api/config is loaded once per page load and is used to retrieve
    # the caching variable which is applied to every other resource
    # which is loaded during that session.
    location ~ ^/api/.*$ {
        proxy_pass http://localhost:3000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # These settings prevent both NGINX and the API server
        # from setting the same headers and creating duplicates
        proxy_hide_header Cross-Origin-Resource-Policy;
        add_header Cross-Origin-Resource-Policy cross-origin;
        proxy_hide_header Cross-Origin-Embedder-Policy;
        add_header Cross-Origin-Embedder-Policy require-corp;
    }

    # encrypted blobs are immutable and are thus cached for a year
    location ^~ /blob/ {
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' "${allowed_origins}";
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'application/octet-stream; charset=utf-8';
            add_header 'Content-Length' 0;
            return 204;
        }
        add_header X-Content-Type-Options nosniff;
        add_header Cache-Control max-age=31536000;
        add_header 'Access-Control-Allow-Origin' "${allowed_origins}";
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Content-Length';
        add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Content-Length';
        try_files $uri =404;
    }

    # the "block-store" serves encrypted payloads containing users' drive keys
    # these payloads are unlocked via login credentials. They are mutable
    # and are thus never cached. They're small enough that it doesn't matter, in any case.
    location ^~ /block/ {
        add_header X-Content-Type-Options nosniff;
        add_header Cache-Control max-age=0;
        try_files $uri =404;
    }

    # This block provides an alternative means of loading content
    # otherwise only served via websocket. This is solely for debugging purposes,
    # and is thus not allowed by default.
    #location ^~ /datastore/ {
        #add_header Cache-Control max-age=0;
        #try_files $uri =404;
    #}

    # The nodejs server has some built-in forwarding rules to prevent
    # URLs like /pad from resulting in a 404. This simply adds a trailing slash
    # to a variety of applications.
    location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban|sheet|support|admin|notifications|teams|calendar|presentation|doc|form|report|convert|checkup)$ {
        rewrite ^(.*)$ $1/ redirect;
    }

    # Finally, serve anything the above exceptions don't govern.
    try_files /customize/www/$uri /customize/www/$uri/index.html /www/$uri /www/$uri/index.html /customize/$uri;
}

Պահպանեք ֆայլը՝ սեղմելով Ctrl + X և մուտքագրելով Y, երբ հուշում է ավարտելուց հետո:

Ստուգեք Nginx կազմաձևման ֆայլի շարահյուսությունը:

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Վերագործարկեք Nginx ծառայությունը:

$ sudo systemctl restart nginx

Քայլ 10 - Ստեղծեք Cryptpad Systemd ծառայություն

Բացեք ~/cryptpad/docs/cryptpad.service ֆայլը խմբագրման համար:

$ nano ~/cryptpad/docs/cryptpad.service

Փոփոխեք դրա ծածկագիրը, որպեսզի նմանվի հետևյալին. Համոզվեք, որ Node երկուականի ճիշտ ուղին է և փոխարինեք username-ին ձեր ներկայումս մուտք գործած Linux օգտվողի անունով:

[Unit]
Description=CryptPad API server

[Service]
ExecStart=/home/username/.nvm/versions/node/v18.14.1/bin/node /home/username/cryptpad/server.js
# modify to match the location of your cryptpad repository
WorkingDirectory=/home/username/cryptpad

Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=2

# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cryptpad
User=username
Group=username
# modify to match your working directory
Environment='PWD="/home/username/cryptpad"'

# systemd sets the open file limit to 4000 unless you override it
# cryptpad stores its data with the filesystem, so you should increase this to match the value of `ulimit -n`
# or risk EMFILE errors.
LimitNOFILE=1000000

[Install]
WantedBy=multi-user.target

Պահպանեք ֆայլը՝ սեղմելով Ctrl + X և մուտքագրելով Y, երբ հուշում է ավարտելուց հետո:

Պատճենեք ֆայլը Systemd թղթապանակում:

sudo cp ~/cryptpad/docs/cryptpad.service /etc/systemd/system/cryptpad.service

Վերբեռնեք ծառայության դեմոնը:

$ sudo systemctl daemon-reload

Միացնել և գործարկել Cryptpad ծառայությունը:

$ sudo systemctl enable cryptpad --now

Ստուգեք ծառայության կարգավիճակը:

$ suddo systemctl status cryptpad

Դուք կստանաք հետևյալ արդյունքը.

? cryptpad.service - CryptPad API server
     Loaded: loaded (/etc/systemd/system/cryptpad.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-02-21 08:43:50 UTC; 1h 52min ago
   Main PID: 8145 (node)
      Tasks: 33 (limit: 2237)
     Memory: 53.4M
        CPU: 2.323s
     CGroup: /system.slice/cryptpad.service
             ??8145 /home/navjot/.nvm/versions/node/v18.14.1/bin/node /home/navjot/cryptpad/server.js
             ??8158 /home/navjot/.nvm/versions/node/v18.14.1/bin/node lib/workers/db-worker
             ??8159 /home/navjot/.nvm/versions/node/v18.14.1/bin/node lib/workers/db-worker

Feb 21 08:43:50 nspeaks systemd[1]: Started CryptPad API server.
Feb 21 08:43:50 nspeaks cryptpad[8145]: Serving content for https://example.com/ via http://127.0.0.1:3000.

Քայլ 11 - Մուտք գործեք և կազմաձևեք Cryptpad-ը

Բացեք https://example.com URL-ը ձեր բրաուզերում և կստանաք հետևյալ էկրանը:

Հաշիվ ստեղծելու համար սեղմեք Գրանցվել կոճակը: Մուտքագրեք ձեր հավատարմագրերը և սեղմեք Գրանցվել կոճակը՝ ձեր հաշիվը ստեղծելու համար:

Դուք կստանաք հետևյալ հաստատման պատուհանը: Կտտացրեք կարմիր կոճակը, որպեսզի ավարտեք հաշիվը ստեղծելու համար:

Դուք մուտք կգործեք և կտեղափոխվեք CryptDrive վահանակ:

Կտտացրեք «Օգտագործողի» ընտրացանկը վերին աջ անկյունում և սեղմեք Կարգավորումներ տարբերակը:

Դուք կստանաք հետևյալ կարգավորումների էջը.

Պատճենեք Հանրային ստորագրման բանալի արժեքը և վերադարձեք տերմինալ և բացեք կազմաձևման ֆայլը:

$ nano ~/cryptpad/config/config.js

Գտեք adminKeys փոփոխականը և փակցրեք բանալին քառակուսի փակագծերի միջև, ինչպես ցույց է տրված ստորև:

adminKeys: ["[[email /ygDc+0uabbCk6WqJYiIDO2B+gP6mYZ9FlQ94zL3UAoU=]"],

Պահպանեք ֆայլը՝ սեղմելով Ctrl + X և մուտքագրելով Y, երբ հուշում է ավարտելուց հետո:

Վերագործարկեք Cryptpad ծառայությունը:

$ sudo systemctl restart cryptpad

Ձեր Cryptpad գրասենյակային փաթեթը պատրաստ է օգտագործման:

Քայլ 12 - Թարմացրեք Cryptpad-ը

Cryptpad-ի թարմացումը բավականին հեշտ է և ներառում է GitHub-ի պահոցից վերջին թարմացումները վերցնելը և այնուհետև գործարկել Node թարմացման հրամանները:

Առաջին քայլը Cryptpad ծառայությունը դադարեցնելն է:

$ sudo systemctl stop cryptpad

Գործարկեք հետևյալ հրամանները՝ Cryptpad-ը թարմացնելու համար:

$ cd ~/cryptpad
$ git pull
$ git checkout $(git tag -l | grep -v 'v1.*$' | sort -V | tail -n 1)
$ npm update
$ bower update

Սկսեք Cryptpad ծառայությունը:

$ sudo systemctl start cryptpad

Եզրակացություն

Սա ավարտում է Ubuntu 22.04 սերվերի վրա Cryptpad Collaborative Office Suite-ի տեղադրման մեր ձեռնարկը: Եթե ունեք հարցեր, տեղադրեք դրանք ստորև ներկայացված մեկնաբանություններում: