Hey Habr!
Haufinyane tjena ke iphumana ke le boemong boo ho bona ho neng ho hlokahala hore ke sebetse ka har'a marang-rang a khoebo a nang le phihlello e sa fellang ho Marang-rang mme, joalo ka ha u ka hakanya ho tsoa sehloohong, Telegraph e ne e koetsoe ho eona. Ke kholisehile hore boemo bona bo tloaelehile ho ba bangata.
Ke khona ho etsa ntle le manqosa a potlakileng, empa e ne e le Telegraph eo ke neng ke e hloka bakeng sa mosebetsi. Ho ne ho sa khonehe ho kenya moreki mochining oa mosebetsi, hape ho ne ho sa khonehe ho sebelisa laptop ea motho. Ho bonahala tharollo e 'ngoe e le ho e sebelisa
Ka lehlohonolo, Webogram ke projeke ea mohloli o bulehileng oo khoutu ea oona e fumanehang ho
Ho kenya le ho qala ka boeona ha ho thata, leha ho le joalo, maemong a ts'ebetso ka har'a marang-rang a nang le phihlello e koetsoeng ho li-server tsa Telegraph, u tla soetseha ho feta katleho, kaha mofuta oa webo o romella likopo ho li-server tsa Telegraph ho tsoa mochining oa mosebelisi.
Ka lehlohonolo, ena ke tokiso e bonolo (empa e sa totobala haholo). Ke rata ho le hlokomelisa hore ha se 'na moqapi oa tharollo ena. Ke khonne ho e fumana
Ka tlase ho sehiloeng u tla fumana mohato ka mohato oa seipone sa hau sa Webogram le ho hlophisa likopo tsa eona ho li-server tsa Telegraph u sebelisa nginx.
E le mohlala, ke khethile Ubuntu Server 18.04.3 e sa tsoa kenngoa le e nchafalitsoeng.
Tlhokomeliso: Thupelo ena e ke ke ea kenyelletsa litaelo tsa ho theha domain name ho nginx. U lokela ho etsa sena u le mong. Thupelo e nka hore u se u ntse u hlophisitse domain name ka ssl, le hore seva ka boeona eo u rerileng ho e hlophisa e na le phihlello ea li-server tsa Telegraph (ka tsela efe kapa efe eo u e ratang)
Ha re nke hore ip ea seva sena ke 10.23.0.3, mme domain name ke mywebogram.localhost
Ho latela litumellano tsena, ke tla fana ka mehlala ea litlhophiso. Se ke oa lebala ho fetola litekanyetso hore e be tsa hau.
Kahoo ha re qaleng:
Ho tsamaisa Webogram, re hloka li-nodejs. Ka kamehla, haeba re e kenya ho tsoa bobolokelong ba Ubuntu, re tla fumana nodejs version 8.x. Re hloka 12.x:
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt update && sudo apt -y install nodejs
Re khetha sebaka seo Webogram ea rona e tla thehoa ho sona.
Ka mohlala, a re e behe motsong oa buka ea lapeng. Ho etsa sena, kopanya polokelo ea semmuso ho seva sa rona:
cd ~ && git clone https://github.com/zhukov/webogram.git
Mohato o latelang ke ho kenya litšepe tsohle tse hlokahalang ho tsamaisa kopo:
cd webogram && npm install
Ha re leke ho etsa liteko. Etsa taelo:
npm start
Ka mor'a moo, re leka ho e bula ka har'a sebatli
http://10.23.0.3:8000/app/index.html
Haeba ho fihlela joale u entse ntho e 'ngoe le e' ngoe ka nepo, leqephe la tumello ea Webogram le tla buleha.
Joale re hloka ho hlophisa sesebelisoa hore se sebetse joalo ka ts'ebeletso. Ho etsa sena, a re theheng faele
sudo touch /lib/systemd/system/webogram.service
e bule ho mohlophisi ofe kapa ofe 'me u fane ka ponahalo e latelang (kenya tsela ea hau ho WorkDirectory)
[Unit]
Description=Webogram mirror
[Service]
WorkingDirectory=/home/tg/webogram
ExecStart=/usr/bin/npm start
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Ebe re tsamaisa litaelo tse latelang:
Ho sebelisa liphetoho
sudo systemctl daemon-reload
Lumella autorun:
sudo systemctl enable webogram.service
Ha re qale tšebeletso:
sudo systemctl start webogram.service
Kamora ho qeta mehato, Webogram e tla tsoelapele ho fumaneha ho port 8000.
Kaha re tla be re theha phihlello ho Webogram ea rona ka nginx, re tla koala port 8000 bakeng sa likopo tse tsoang kantle.
Re sebelisa udf utility bakeng sa sena (kapa mokhoa ofe kapa ofe o loketseng uena):
sudo ufw deny 8000
Haeba u ntse u etsa qeto ea ho sebelisa udf, empa e holofetse ho seva, eketsa melao e meng (e le hore ntho e 'ngoe le e' ngoe e se ke ea senyeha) 'me u nolofalletse udf:
sudo ufw allow ssh
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
Ka mor'a moo, a re qaleng ho fetola tlhophiso ea nginx.
Joalokaha ke lemositse ka holimo, ho nahanoa hore sebaka se nang le ssl se se se hlophisitsoe ho seva sa hau. Ke tla lebisa tlhokomelo ea hau ho se tla hloka ho kenyelletsoa faeleng ea tlhophiso ea domain hore e sebetse ka nepo:
server {
...
location ^~ /pluto/apiw1/ {
proxy_pass https://pluto.web.telegram.org/apiw1/;
}
location ^~ /venus/apiw1/ {
proxy_pass https://venus.web.telegram.org/apiw1/;
}
location ^~ /aurora/apiw1/ {
proxy_pass https://aurora.web.telegram.org/apiw1/;
}
location ^~ /vesta/apiw1/ {
proxy_pass https://vesta.web.telegram.org/apiw1/;
}
location ^~ /flora/apiw1/ {
proxy_pass https://flora.web.telegram.org/apiw1/;
}
location ^~ /pluto-1/apiw1/ {
proxy_pass https://pluto-1.web.telegram.org/apiw1/;
}
location ^~ /venus-1/apiw1/ {
proxy_pass https://venus-1.web.telegram.org/apiw1/;
}
location ^~ /aurora-1/apiw1/ {
proxy_pass https://aurora-1.web.telegram.org/apiw1/;
}
location ^~ /vesta-1/apiw1/ {
proxy_pass https://vesta-1.web.telegram.org/apiw1/;
}
location ^~ /flora-1/apiw1/ {
proxy_pass https://flora-1.web.telegram.org/apiw1/;
}
location ^~ /DC1/ {
proxy_pass http://149.154.175.10:80/;
}
location ^~ /DC2/ {
proxy_pass http://149.154.167.40:80/;
}
location ^~ /DC3/ {
proxy_pass http://149.154.175.117:80/;
}
location ^~ /DC4/ {
proxy_pass http://149.154.175.50:80/;
}
location ^~ /DC5/ {
proxy_pass http://149.154.167.51:80/;
}
location ^~ /DC6/ {
proxy_pass http://149.154.175.100:80/;
}
location ^~ /DC7/ {
proxy_pass http://149.154.167.91:80/;
}
location ^~ /DC8/ {
proxy_pass http://149.154.171.5:80/;
}
location / {
auth_basic "tg";
auth_basic_user_file /etc/nginx/passwd.htpasswd;
proxy_pass http://localhost:8000/;
proxy_read_timeout 90s;
proxy_connect_timeout 90s;
proxy_send_timeout 90s;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
Seo re se kenyelletsang ho nginx config:
- Re fetola sebaka sa motso, se tla kopa moemeli ho port 8000, moo Webogram e arabelang teng
- Re koala sebaka sa motso re sebelisa base-auth. Ona ke mohato oa tšoantšetso oa ho koala ts'ebeliso ea rona ho tsoa mahlo le bots. (Mme hape ho qoba mathata ka ho thibela)
- Libaka tse ngata tse nang le proxy_path ho seva ea Telegraph ke liphetho tsa rona tseo ka tsona re tla emela likopo tsa rona.
Hape, ha re theheng faele /etc/nginx/passwd.htpasswd;
e le hore nginx e be le ho hong ho hlahloba li-password tsa basebelisi.
sudo apt install apache2-utils
sudo htpasswd -c /etc/nginx/passwd.htpasswd tg
Qala hape nginx:
sudo systemctl restart nginx
Hona joale Webogram e tla fumaneha feela ho
Ho na le ho honyenyane ho setseng: re tla etsa liphetoho tse nyenyane morerong ka boeona.
Bula faele ka har'a mohlophisi ~/webogram/app/js/lib/mtproto.js
Ebe u qala ka mokhoa o latelang:
/*!
* Webogram v0.7.0 - messaging web application for MTProto
* https://github.com/zhukov/webogram
* Copyright (C) 2014 Igor Zhukov <[email protected]>
* https://github.com/zhukov/webogram/blob/master/LICENSE
*/
angular.module('izhukov.mtproto', ['izhukov.utils'])
.factory('MtpDcConfigurator', function () {
var sslSubdomains = ['pluto', 'venus', 'aurora', 'vesta', 'flora']
var dcOptions = Config.Modes.test
? [
{id: 1, host: 'mywebogram.localhost/DC1', port: 80},
{id: 2, host: 'mywebogram.localhost/DC2', port: 80},
{id: 3, host: 'mywebogram.localhost/DC3', port: 80}
]
: [
{id: 1, host: 'mywebogram.localhost/DC4', port: 80},
{id: 2, host: 'mywebogram.localhost/DC5', port: 80},
{id: 3, host: 'mywebogram.localhost/DC6', port: 80},
{id: 4, host: 'mywebogram.localhost/DC7', port: 80},
{id: 5, host: 'mywebogram.localhost/DC8', port: 80}
]
var chosenServers = {}
function chooseServer (dcID, upload) {
if (chosenServers[dcID] === undefined) {
var chosenServer = false,
i, dcOption
if (Config.Modes.ssl || !Config.Modes.http) {
var subdomain = sslSubdomains[dcID - 1] + (upload ? '-1' : '')
var path = Config.Modes.test ? 'apiw_test1' : '/apiw1/'
chosenServer = 'https://mywebogram.localhost/' + subdomain + path
return chosenServer
}
for (i = 0; i < dcOptions.length; i++) {
dcOption = dcOptions[i]
if (dcOption.id == dcID) {
chosenServer = 'http://' + dcOption.host + '/apiw1'
break
}
}
chosenServers[dcID] = chosenServer
}
...
Kamora sena, o hloka ho nchafatsa leqephe la ts'ebeliso ho sebatli.
Bula khomphutha ea hau ea sebatli 'me u shebe likopo tsa marang-rang tsa sesebelisoa. Haeba ntho e 'ngoe le e' ngoe e sebetsa 'me likōpo tsa XHR li ea ho seva sa hau, joale ntho e' ngoe le e 'ngoe e etsoa ka nepo,' me hona joale Webogram e se e le proxied ka nginx.
Ke tšepa hore thuto ena e tla ba molemo ho motho e mong ntle le 'na.
Re leboha bohle ba badileng ho fihlela qetellong.
Haeba mang kapa mang a e-na le mathata kapa ke entse liphoso, ke tla thabela ho araba le ho leka ho u thusa ho maikutlo kapa ho PM.
Source: www.habr.com