Preduvjeti
Instalirajte potrebne pakete
Izgradnja poslužitelja
Konfiguracija poslužitelja za sinkronizaciju
Pokretanje Sync Server
Konfiguracija web poslužitelja
Konfigurirajte klijenta (Firefox)
Firefox Sync je značajka sinkronizacije preglednika koja vam omogućuje dijeljenje vaših podataka i postavki (kao što su vaše oznake, povijest, lozinke, otvorene kartice i instalirani dodaci) na svim vašim uređajima. Mozilla također nudi aplikaciju "poslužitelj za sinkronizaciju" za korištenje s Firefox Sync za korisnike i tvrtke koje preferiraju hostirati vlastite podatke za sinkronizaciju. Ovaj vam članak pokazuje kako postaviti Mozilla Sync Server.
Preduvjeti
- Novopostavljeni Vultr CentOS 6
- Korisnik sudoa .
Instalirajte potrebne pakete
Ažurirajte sustav:
sudo yum check-update
Da biste izgradili i pokrenuli Sync Server, morat ćete instalirati ove pakete:
Mecurial
sqlite3
git
Python 2.6.6
Python 2.6.6 virtualenv
Python 2.6.6 SetupTools
Python 2.6.6 Developer Tools
Instalirajte najnoviju verziju Mercuriala:
sudo yum install mercurial
Instalirajte potrebne razvojne alate i knjižnice:
yum groupinstall 'Development Tools' 'Development Libraries'
yum install tk-devel libjpeg-devel mysql-devel python-devel httpd-devel zlib-devel bzip2-devel
Instalirajte SQLite3:
sudo yum install sqlite
Instalirajte i izgradite Python 2.6.6:
cd $home
sudo wget http://python.org/ftp/python/2.6.6/Python-2.6.6.tgz
sudo tar xzvf Python-2.6.6.tgz
cd $home/Python-2.6.6
sudo ./configure --prefix=/opt/python2.6 --enable-thread --enable-shared --enable-unicode=ucs4
sudo make
sudo make install
Izgradnja poslužitelja
Klonit ćemo Git repozitorij poslužitelja za sinkronizaciju i zatim ući u mapu:
git clone https://github.com/mozilla-services/syncserver
cd syncserver
Pokrenite naredbu build koja će preuzeti ovisnosti i prevesti kod:
make build
Pokrenite Sync Server i provjerite radi li ispravno:
bin/paster serve development.ini
Vidjet ćete nešto poput ovoga:
Starting server in PID 5952.
serving on 0.0.0.0:5000 view at http://127.0.0.1:5000
Konfiguracija poslužitelja za sinkronizaciju
Konfiguracija poslužitelja za sinkronizaciju je vrlo jednostavna, postoji samo nekoliko parametara za promjenu u konfiguracijskoj datoteci ( ./syncserver.ini).
Otvorite konfiguracijsku datoteku svojim omiljenim uređivačem teksta (na primjer nano ./syncserver.ini).
[server:main]
use = egg:gunicorn
host = 0.0.0.0
port = 5000
workers = 1
timeout = 30
[app:main]
use = egg:syncserver
[syncserver]
# This must be edited to point to the public URL of your server,
# i.e. the URL as seen by Firefox.
public_url = http://localhost:5000/
# This defines the database in which to store all server data.
#sqluri = sqlite:////tmp/syncserver.db
# This is a secret key used for signing authentication tokens.
# It should be long and randomly-generated.
# The following command will give a suitable value on *nix systems:
#
# head -c 20 /dev/urandom | sha1sum
#
# If not specified then the server will generate a temporary one at startup.
#secret = INSERT_SECRET_KEY_HERE
# Set this to "false" to disable new-user signups on the server.
# Only request by existing accounts will be honoured.
# allow_new_users = false
# Set this to "true" to work around a mismatch between public_url and
# the application URL as seen by python, which can happen in certain reverse-
# proxy hosting setups. It will overwrite the WSGI environ dict with the
# details from public_url. This could have security implications if e.g.
# you tell the app that it's on HTTPS but it's really on HTTP, so it should
# only be used as a last resort and after careful checking of server config.
force_wsgi_environ = false
[browserid]
# Uncomment and edit the following to use a local BrowserID verifier
# rather than posting assertions to the mozilla-hosted verifier.
# Audiences should be set to your public_url without a trailing slash.
#backend = tokenserver.verifiers.LocalVerifier
#audiences = https://localhost:5000
# By default, syncserver will accept identity assertions issues by
# any server. You can restrict this by setting the below to a list
# of allowed issuer domains.
#allowed_issuers = www.mysite.com myfriendsdomain.org
Adresa vašeg poslužitelja mora biti navedena putem parametra public_url:
public_url = http://fsync.example.com
Napomena : zadana vrijednost public_url, http://localhost:5000/, radit će za potrebe testiranja na vašem lokalnom računalu.
Dekomentirati ćemo sqluriopciju i staviti lokaciju ili URI, koja će omogućiti poslužitelju da poveže bazu podataka i pohrani svoje podatke:
sqluri = sqlite:////path/to/database/file.db
Ako želite koristiti drugu vrstu DB-a:
sqluri = pymysql://username:password@db.example.com/sync
Za secretparametar ćemo morati generirati tajni ključ za autentifikacijske tokene:
head -c 20 /dev/urandom | sha1sum
Odkomentirajte redak tajnog parametra i zatim kopirajte/zalijepite vraćeni niz u tajni parametar:
secret = db8a203aed5fe3e4594d4b75990acb76242efd35
Napomena : Ako ništa ne unesete u ovaj parametar, poslužitelj će ga generirati, ali će biti drugačiji svaki put kada se poslužitelj ponovno pokrene.
Dekomentirajte allow\_new\_usersparametar i postavite ga tako trueda omogućite našem računu da se prvi put poveže s našim poslužiteljem:
allow_new_users = true
Zatim ćemo dekomentirati audiencesparametar i staviti isto što i public_uriparametar:
audiences = http://fsync.example.com
Na kraju, samo dodajte sljedeći redak na kraj datoteke:
forwarded_allow_ips = *
Ova će vam linija pomoći da izbjegnete poruke o pogrešci i probleme s autorizacijom.
Pokretanje Sync Server
Da biste pokrenuli poslužitelj za sinkronizaciju, možete koristiti jednu od sljedećih naredbi:
./path/to/syncserver/local/bin/gunicorn --threads 4 --paste /path/to/syncserver/syncserver.ini &
To vam omogućuje da odaberete mjesto konfiguracijske datoteke; kao i stavite argument --threads 4, koji omogućuje dodjeljivanje više snage poslužitelju za sinkronizaciju.
Za pokretanje poslužitelja svaki put kada se vaša instanca pokrene, možete dodati sljedeći redak u svoj crontab upisivanjem crontab -enaredbe:
@reboot ./path/to/syncserver/local/bin/gunicorn --paste /path/to/syncserver/syncserver.ini &
Konfiguracija web poslužitelja
Možete koristiti različite web poslužitelje koji su kompatibilni s WSGIprotokolom. Na primjer:
Nginx s uWSGI.
Apache u kombinaciji s mod_wsgi.
Nginx
Za Nginx morate koristiti Nginxov ugrađeni proxy kao što je prikazano u nastavku:
server {
listen 80;
server_name fsync.example.com;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_read_timeout 120;
proxy_connect_timeout 10;
proxy_pass http://127.0.0.1:5000/;
}
}
Nginx + uWSGI
Korisnicima Nginxa moguće je koristiti samo WSGI utičnicu.
Instaliraj uWSGIputem Pipa:
pip install uwsgi
Instalirajte uWSGIpreuzimanjem izvornog tarball-a:
wget https://projects.unbit.it/downloads/uwsgi-latest.tar.gz
tar zxvf uwsgi-latest.tar.gz
cd <dir>
make
Napomena : Nakon izgradnje, imat ćete uwsgibinarnu datoteku u trenutnom direktoriju.
Nakon instalacije, pokrenite ga sa sljedećim opcijama:
uwsgi --plugins python27 --manage-script-name \
--mount /<location>=/path/to/syncserver/syncserver.wsgi \
--socket /path/to/uwsgi.sock
Zatim upotrijebite sljedeću konfiguraciju Nginxa:
location /<location>/ {
include uwsgi_params;
uwsgi_pass unix:/path/to/uwsgi.sock;
}
Apache
Instaliraj mod_wsgi:
apt-get install libapache2-mod-wsgi
Zatim upotrijebite sljedeći vhost:
<VirtualHost *:80>
ServerName sync.example.com
DocumentRoot /path/to/syncserver
WSGIProcessGroup sync
WSGIDaemonProcess sync user=sync group=sync processes=2 threads=25 python-path=/path/to/syncserver/local/lib/python2.7/site-packages/
WSGIPassAuthorization On
WSGIScriptAlias / /path/to/syncserver/syncserver.wsgi
CustomLog /var/log/apache2/sync.example.com-access.log combined
ErrorLog /var/log/apache2/sync.example.com-error.log
</VirtualHost>
Nakon što je poslužitelj instaliran i konfiguriran, možete konfigurirati desktop Firefox klijent za razgovor s vašim novim Sync Server. Prije nego što počnete, morate se odjaviti ako ste već povezani s Firefox Sync poslužiteljima. Inače, veza s novim poslužiteljem možda neće raditi.
Prvo otvorite novu karticu i unesite sljedeću adresu:
about:config
U traku za pretraživanje unesite identity.sync.tokenserver.urii promijenite njezinu vrijednost u URL vašeg poslužitelja sa stazom token/1.0/sync/1.5:
http://sync.example.com/token/1.0/sync/1.5