Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anki 2.1.49 will not sync via https proxy #154

Open
pajot opened this issue Nov 16, 2022 · 2 comments
Open

Anki 2.1.49 will not sync via https proxy #154

pajot opened this issue Nov 16, 2022 · 2 comments

Comments

@pajot
Copy link

pajot commented Nov 16, 2022

I have anki-sync-server running behind an nginx web server.

The nginx configuration looks like this:

server {
        listen       27701 ssl;
        server_name   dummy.net;


        ssl_certificate /etc/letsencrypt/live/dummy.net/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/dummy.net/privkey.pem;

        location / {
            proxy_http_version 1.0;
            proxy_pass         http://127.0.0.1:27702/;
            client_max_body_size 222M;
        }
    }

nginx listens on port 27701 and anki-sync-server on 27702.

tcp       LISTEN     0          511                                    0.0.0.0:27701               0.0.0.0:*                                                                                                                            
tcp       LISTEN     0          5                                    127.0.0.1:27702               0.0.0.0:*         users:(("python",pid=223409,fd=3))                                                                               

I configure the add-on manually using the instructions for > 2.1.28:

import os

addr = "https://dummy.net:27701/" # put your server address here
os.environ["SYNC_ENDPOINT"] = addr + "sync/"
os.environ["SYNC_ENDPOINT_MEDIA"] = addr + "msync/"

But when I try to sync, I get an error dialog telling me to check the database and try again. On the server side, I see this in the nginx error.log:

2022/11/16 00:09:41 [info] 199330#0: *35105 client sent plain HTTP request to HTTPS port while reading client request headers, client: <address>, server: dummy.net, request: "POST /sync/hostKey HTTP/1.1", host: "dummy.net:27701"

And nothing in the ankisyncd console output.

If I query the server with curl https://dummy.net:27701, I get
Anki Sync Server

If I query it with curl https://dummy.net:27701/sync/hostKey, I get
A server error occurred. Please contact the administrator.

and

[2022-11-16 00:42:57,861]:INFO:ankisyncd.http:127.0.0.1 "GET /sync/hostKey HTTP/1.0" 500 59

in the ankisyncd console output.

(But this is probably because my API request is not formatted correctly.)

It would appear that Anki is not speaking https, despite having specified it in the add-on configuration.

@dglava
Copy link

dglava commented Nov 19, 2022

Have you tried it with this addon: https://ankiweb.net/shared/info/358444159 ?
I am also using an NGINX reverse proxy with HTTPS (pretty much the same configuration as you) with Anki 2.1.54 and I have

{
    "syncaddr": "https://domain.com/anki/"
}

in the addon's settings and it works without issues.

@pajot
Copy link
Author

pajot commented Feb 13, 2023

Yes, I've tried it with custom sync server redirector and I get this error message when syncing:

error decoding response body: expected value at line 1 column 1⁩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants