Mokhoa oa ho kenya Sails.js Framework le Nginx ho Rocky Linux 9

Sails.js ke moralo o matla oa Javascript o etsang hore ho be bonolo ho aha lits'ebetso tsa Node.js tsa boemo ba khoebo. E tšoana le meralo ea MVC ea meralo e kang Ruby on Rails empa e na le ts'ehetso e ntlafalitsoeng bakeng sa mokhoa oa sejoale-joale oa nts'etsopele ea webo o shebaneng le data. Ho feta moo, Sails.js e lumellana le mefuta e mengata ea theknoloji ea pele, ho kenyelletsa Angular, React, iOS, Android, le Windows Phone. Sena se etsa hore e be se loketseng ho nts'etsapele lits'ebetso tse rarahaneng tsa webo tse tlamehang ho sebetsa li-platform tse ngata. Ka likarolo tsa eona tse matla le API e bonolo ho e sebelisa, Sails.js ke sesebelisoa se phethahetseng sa ho aha lits'ebetso tsa boleng bo holimo tsa Node.js.

Thutong e latelang, o tla ithuta ho kenya Sails.js ho Rocky Linux 9 le ho fihlella sebopeho sa marang-rang ka ho kenya le ho hlophisa setaele sa proxy sa Nginx..

Kenya Liphutheloana Tse Hlokehang

Mosebetsi oa pele ke ho hlahloba kapa ho kenya liphutheloana tse latelang ka ho sebelisa taelo e latelang.

sudo dnf install curl gcc-c++ make -y

Hang ha litšepeho li kentsoe, u tla hloka hape ho kenya Node.js.

Thupelo e tla kenya mofuta oa morao-rao o tsitsitseng oa NPM, empa o ka fetola sena ho mofuta ofe kapa ofe o mong o ntseng o tšehetsoa.

Taba ea pele, kenya polokelo ea Node.js u sebelisa taelo e latelang ea terminal.

curl -fsSL https://rpm.nodesource.com/setup_current.x | sudo bash -

Lintlha tse ling mabapi le phetolelo ea morao-rao li ka fumanoa ka ho etela NodeSource.

E latelang, kenya Node.js.

sudo dnf install nodejs -y

Kenya Sails.js

Karolo e latelang ea ho kenya e tla sebelisa NPM ho kenya Sails.js. Ho etsa sena, sebelisa taelo e latelang.

sudo npm -g install sails

Qetellong, etsa bonnete ba hore NPM ea hau e nakong u sebelisa taelo e latelang. Sena se bohlokoa; o seke wa tlola.

sudo npm install [email protected] -g

Kaha joale Sails.js e kentsoe, mohato o latelang ke ho theha projeke e ncha eo u ka e bitsang eng kapa eng eo u e ratang, empa e tla bitsoa. "testapp" bakeng sa thuto.

Ntlha ea pele, theha directory, e ka fumanoang kae kapa kae. Hlokomela feela sebaka se felletseng bakeng sa ts'ebeletso ea systemd hamorao. Thupelo e tla sebelisa www directory.

sudo mkdir -p /var/www/ && cd /var/www/

Theha "testapp" u sebelisa taelo e latelang.

sudo sails new testapp

Ho tla botsoa molaetsa ho khetha template bakeng sa ts'ebeliso ea hau ea Sails.

mohlala:

Mokhoa oa ho kenya Sails.js Framework le Nginx ho Rocky Linux 9

thaepa 2 'me u hatelle TSENA KENYA ho tsoela pele le ho tlatsa "testapp" popo.

mohlala:

Mokhoa oa ho kenya Sails.js Framework le Nginx ho Rocky Linux 9

Ka mor'a moo, tsamaea 'me u qale ho bula "testapp" ho etsa teko le ho netefatsa.

cd testapp && sudo sails lift

Mohlala oa tlhahiso:

Mokhoa oa ho kenya Sails.js Framework le Nginx ho Rocky Linux 9

Ho tsoa, ​​​​sebelisa (CTRL+C) taelo.

Theha Faele ea Tšebeletso ea Systemd bakeng sa Sails.js

Ho ba le ho laola tšebeletso ea systemd bakeng sa Sails.js, o tlameha ho theha faele ea tšebeletso ea systemd.

Etsa faele ea tšebeletso u sebelisa taelo e latelang.

sudo nano /lib/systemd/system/sails.service

Ka mor'a moo, kopitsa le ho beha tse latelang.

[Unit]
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/var/www/testapp
ExecStart=/usr/bin/sails lift
Restart=on-failure

[Install]
WantedBy=multi-user.target

mohlala:

Mokhoa oa ho kenya Sails.js Framework le Nginx ho Rocky Linux 9

Hlokomela, haeba u beha sebaka sa Sail.js sa directory sebakeng se fapaneng, fetola “WorkingDirectory=/var/www/testapp” tsela ea tšebeletso ea systemd.

Boloka faele (CTRL+O), ebe oa tsoa (CTLR+X).

E latelang, kenya daemon ea systemd hape.

sudo systemctl daemon-reload

E latelang, qala tšebeletso ea Sails.js 'me u e nolofalletse ho qala ha sistimi e qala hape:

sudo systemctl enable sails --now

Joale netefatsa boemo ba tšebeletso ea Sails.js ka taelo e latelang.

systemctl status sails

Mohlala oa tlhahiso:

Mokhoa oa ho kenya Sails.js Framework le Nginx ho Rocky Linux 9

Kenya 'me u lokise Proxy e Reverse

Kenya Nginx

Thupelo e tla sebelisa Nginx e le moemeli oa morao oa ho sebelisa Sails. Li-proxies tse ling tse ka morao li ka sebelisoa. Leha ho le joalo, Nginx e otlolohile ebile e tšepahala ho ts'ireletso le ts'ebetso ho feta likhetho tse ling tse ngata.

Taba ea pele, kenya mofuta oa kamehla oa Nginx o fumanehang ho Rocky Linux 9.

sudo dnf install nginx -y

Ka mor'a moo, netefatsa hore na ketso ea mofuta ofe e hahiloe le haeba ts'ebetso e atlehile.

nginx -v

Pele o tsoela pele, o tlameha ho qala ts'ebeletso ea Nginx.

sudo systemctl enable nginx --now

E latelang, netefatsa boemo ho netefatsa hore ha ho na liphoso.

systemctl status nginx

Mohlala oa tlhahiso haeba tsohle li sebetsa hantle:

Mokhoa oa ho kenya Sails.js Framework le Nginx ho Rocky Linux 9

Lokisa Nginx joalo ka Moemeli oa Reverse

Ka mor'a moo, theha sebaka sa seva (moamoheli oa sebele) bakeng sa sesebelisoa sa Sails. Sena se ka etsoa ka mohlophisi oa mongolo oo u o ratang haholo.

mohlala:

sudo nano /etc/nginx/conf.d/sails.conf

Joale kopitsa le ho beha tse latelang ka ho fetola faele ea "mohlala.com" domain name ho ea hau.

server {
 listen       80;
 server_name  sails.example.com;
   location / {
     proxy_pass        http://localhost:1337/;
     proxy_set_header  Host $host;
     proxy_buffering   off;
   }
 }

Boloka faele (CTRL+O), ebe oa tsoa (CTRL+X).

Ka mor'a moo, hlahloba hore na faele ea tlhophiso ea sebetsa 'me ha ho na liphoso.

sudo nginx -t

Mohlala oa tlhahiso haeba ho se na liphoso:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Qala ts'ebeletso hang ha Nginx e khutlisa boemo bo nepahetseng nakong ea tlhahlobo e omileng.

sudo systemctl restart nginx

Lokisa Melao ea FirewallD

Ha ho melao ea firewall e behiloeng boema-kepeng bo tloaelehileng ba 80 kapa 443 ha u kenya Nginx. Pele o tsoela pele, o lokela ho beha melao e latelang, sena se tla itšetleha ka hore na u tla sebelisa likou life, empa likhetho tsohle li thathamisitsoe.

Bula port 80 kapa HTTP:

sudo firewall-cmd --permanent --zone=public --add-service=http

Bula port 443 kapa HTTPS:

sudo firewall-cmd --permanent --zone=public --add-service=https

Kenya firewall hape ho etsa liphetoho

sudo firewall-cmd --reload

Hlokomela hore o ka theha HTTPS hamorao thutong haeba o sa tiisehe.

Fumana Sails.js Web Interface

Kaha joale u se u atlehile ho instola le ho lokisa sails.js le Nginx joalo ka moemeli oa ka morao, u ka bula lits'ebetso tsa hau tsa Sails.js ka ho etela sebaka seo u se boletseng ka ho bula Sebadi sa Marang-rang seo u se ratang le ho ngola tse latelang.

http://salis.example.com

Haeba u atlehile, u lokela ho bona leqephe la kamehla la Sails.js la ho lulisa.

mohlala:

Mokhoa oa ho kenya Sails.js Framework le Nginx ho Rocky Linux 9

Kea u lebohela, u atlehile ho kenya Sails.js.

Sireletsa Nginx ka Let's Encrypt SSL Free Certificate

Haele hantle, o ka batla ho tsamaisa seva sa hau sa marang-rang sa Apache ho HTTPS o sebelisa setifikeiti sa SSL. Mokhoa o motle oa ho etsa sena ke ho sebelisa Let's Encrypt, setifikeiti sa mahala, se ikemetseng, le se bulehileng se tsamaisoang ke mokhatlo o sa etseng phaello oa Internet Security Research Group (ISRG).

Rocky Linux 9 ke e 'ngoe ea likhatiso tse' maloa ntle le Certbot e fumanehang ka DNF. Leha ho le joalo, o ka kenya snap ho laola sena ho fihlela EPEL/EPEL Next 9 e fihla.

Ntlha ea pele, kenya snapd.

sudo dnf install snapd -y

Ha e se e kentsoe, e lumelle hang-hang le ha o qala sistimi ho beha leihlo bakeng sa lintlafatso.

sudo systemctl enable snapd --now

Ka mor'a moo, kenya snap core ho koahela litšepe tsohle tse hlokahalang bakeng sa liphutheloana tsa snap.

sudo snap install core

Theha symlink bakeng sa foldara ea snapd.

sudo ln -s /var/lib/snapd/snap /snap

Kenya sephutheloana sa Certbot snap.

sudo snap install --classic certbot

Qetellong, theha symlink e 'ngoe bakeng sa certbot.

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

Ha e se e kentsoe, tsamaisa taelo e latelang ho qala ho theha setifikeiti sa hau:

sudo certbot --dry-run --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d www.example.com

Ntle le moo, sebelisa taelo e latelang 'me u latele litlhahiso haeba li fumaneha haholoanyane.

sudo certbot certonly --nginx

Setupo sena se nepahetseng se kenyelletsa matla a ho tsamaisa HTTPS 301, hlooho ea Strict-Transport-Security, le OCSP Stapling. Etsa bonnete ba hore u fetola lengolo-tsoibila le lebitso la domain ho latela litlhoko tsa hau.

Joale URL ea hau e tla ba teng HTTPS://sails.example.com sebakeng sa HTTP://sails.example.com.

Ka boikhethelo, o ka seta mosebetsi oa cron ho nchafatsa setifikeiti ka bohona. Certbot e fana ka script e etsang sena ka bo eona, 'me u ka qala ho etsa liteko ho netefatsa hore ntho e' ngoe le e 'ngoe e ea sebetsa ka ho omella.

sudo certbot renew --dry-run

E latelang, sebelisa li-systemctl-timer ho netefatsa hore ho na le mosebetsi oa cron o sebetsang hajoale ho lekola le ho nchafatsa setifikeiti sa hau.

systemctl list-timers

Ho na le sebali-nako se tla hlahloba le ho nchafatsa setifikeiti pele se fela, kahoo ha ho hlokahale hore u tšoenyehe hape.

Maikutlo le Qetello

Haeba u batla sebopeho sa Javascript se matla le se bonolo ho se sebelisa se tla u thusa ho aha lits'ebetso tsa webo tse ikhethileng kapele, Sails.js ke khetho e ntle eo u ka e nahanang. Ka meaho ea eona ea MVC le ho tsamaellana le meralo e meng e tsebahalang ea pheletso e ka pele, e tla etsa hore ts'ebetso ea hau ea ntlafatso e be bonolo le kapele.



Latela LinuxCapable.com!

Na u rata ho fumana liapdeite? Re latele ho e 'ngoe ea li-account tsa rona tsa litaba tsa sechaba!