Skip to content

Anki 2.1.49 will not sync via https proxy #154

@pajot

Description

@pajot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions