dsnopek / anki-sync-server

A personal Anki sync server (so you can sync against your own server rather than AnkiWeb)
GNU Affero General Public License v3.0
741 stars 95 forks source link

Tips for using Ankiserver on a local network with different machines #62

Open gabriellluz opened 7 years ago

gabriellluz commented 7 years ago

My production.ini files At server:main, in host, put your host/ip as the same in your local network. If your IP is always changing, you have to open your Router page and assign an IP to your machine so that it always grabs the same IP when you connect your machine to the router.

Look for the line with "allowed_host" and remove it. It will work flawlessly.

[server:main]
use = egg:AnkiServer#server
host = 192.168.1.105
port = 27701

[filter-app:main]
use = egg:Paste#translogger
next = real

[app:real]
use = egg:Paste#urlmap
/ = rest_app
/msync = sync_app
/sync = sync_app

[app:rest_app]
use = egg:AnkiServer#rest_app
data_root = ./collections
;logging.config_file = logging.conf

[app:sync_app]
use = egg:AnkiServer#sync_app
data_root = ./collections
base_url = /sync/
base_media_url = /msync/
session_db_path = ./session.db
auth_db_path = ./auth.db

My "mysyncserver.py" file looks like this:

import anki.sync
import httplib2
anki.sync.SYNC_BASE = 'http://192.168.1.105:27701/'
anki.sync.SYNC_MEDIA_BASE = 'http://192.168.1.105:27701/msync/'
anki.sync.httpCon = lambda: httplib2.Http()

In order to make it work outside network (using internet, 3g, 4g etc), you can use this tutorial: http://www.htpcguides.com/get-nag-free-dynamic-dns-with-freedns/

hmgqzx commented 5 years ago

I installed the server on my local mac. I set the data_root as the same as the default folder of the AnkiDesktop then I don't need sync the server folder with the default folder.

Noted: When you want to log in from the AnkiDesktop, you should stop the ./ankiserverctl.py server. Otherwise, AnkiDesktop would go wrong and remind you. Only start the server when you want to sync with your mobie Anki.

the production.ini is like:

[server:main]
use = egg:AnkiServer#server

;my mac ip in the router
host = 17x.2x.4x.5x

port = 27701

[filter-app:main]
use = egg:Paste#translogger
next = real

[app:real]
use = egg:Paste#urlmap
/ = rest_app
/msync = sync_app
/sync = sync_app

[app:rest_app]
use = egg:AnkiServer#rest_app

;data_root = ./collections  ---> change this line
data_root = /Users/me/Library/Application Support/Anki2

;allowed_hosts = 127.0.0.1 ---> comment this line
;logging.config_file = logging.conf

[app:sync_app]
use = egg:AnkiServer#sync_app
data_root = /Users/me/Library/Application Support/Anki2
base_url = /sync/
base_media_url = /msync/
session_db_path = ./session.db
auth_db_path = ./auth.db