RESTful API allowed hosts

105 views
Skip to first unread message

jim...@gmail.com

unread,
Aug 22, 2016, 2:20:56 AM8/22/16
to Anki Sync Server
Hello again,

I am quite new at this, but I have managed to get AnkiServer-2.0.6 running on a Raspberry Pi 3 & Ubuntu 16.04 on port 27701. I'm also running an Nginx server on port 80. Everything is on a local lan. 

Syncing my clients works perfectly, but when trying to use the RESTful API, and I POST to my AnkiServer url, teamserver.lan:27701, I get 403 forbidden which leads me to believe my allowed hosts is not configured correctly. How do I set a port for allowed hosts in production.ini, or do I even need to?

Here is production.ini:

[server:main]
use = egg:AnkiServer#server
host = teamserver.lan
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
allowed_hosts = teamserver.lan
;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


Here are some curl attempts from my client on the lan:

jim@jimbook-ubuntu:~$ curl -v teamserver.lan
* Rebuilt URL to: teamserver.lan/
*   Trying 192.168.2.70...
* Connected to teamserver.lan (192.168.2.70) port 80 (#0)
> GET / HTTP/1.1
> Host: teamserver.lan
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.10.0 (Ubuntu)
< Date: Mon, 22 Aug 2016 05:16:30 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< Vary: Accept-Encoding, Cookie
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Cache-Control: private, must-revalidate, max-age=0
< Last-Modified: Mon, 22 Aug 2016 05:16:30 GMT
<
* Connection #0 to host teamserver.lan left intact
jim@jimbook-ubuntu:~$ curl -v teamserver.lan:27701/sync
*   Trying 192.168.2.70...
* Connected to teamserver.lan (192.168.2.70) port 27701 (#0)
> GET /sync HTTP/1.1
> Host: teamserver.lan:27701
> User-Agent: curl/7.47.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: PasteWSGIServer/0.5 Python/2.7.12
< Date: Mon, 22 Aug 2016 05:16:44 GMT
< Content-Type: text/plain; charset=UTF-8
< Content-Length: 16
<
* Closing connection 0
Anki Sync Serverjim@jimbook-ubuntu:~$ curl -v teamserver.lan:27701
* Rebuilt URL to: teamserver.lan:27701/
*   Trying 192.168.2.70...
* Connected to teamserver.lan (192.168.2.70) port 27701 (#0)
> GET / HTTP/1.1
> Host: teamserver.lan:27701
> User-Agent: curl/7.47.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 403 Forbidden
< Server: PasteWSGIServer/0.5 Python/2.7.12
< Date: Mon, 22 Aug 2016 05:17:03 GMT
< Content-Length: 55
< Content-Type: text/plain; charset=UTF-8
<
403 Forbidden

Access was denied to this resource.


* Closing connection 0

Thanks in advance for your help!

Jim 



Reply all
Reply to author
Forward
0 new messages