map_hash_bucket_size 128;

map $request_uri $redirect_uri {
    # old www.qownnotes.org
    /changelog/QOwnNotes /changelog.html;
    /shortcuts/QOwnNotes /getting-started/shortcuts.html;
    /Knowledge-base/QOwnNotes-Web-Companion-browser-extension /getting-started/browser-extension.html;
    /Knowledge-base/How-can-I-help-to-translate-QOwnNotes /contributing/translation.html;
    /Knowledge-base/How-can-I-get-involved-with-QOwnNotes /contributing/get-involved.html;
    ~*Knowledge-base.* /getting-started/concept.html;
    #~*Blog.* /;
    /donate /contributing/donate.html;

    # old docs.qownnotes.org
    /en/latest/ /getting-started/overview.html;
    /en/latest/scripting/ /scripting;
    ~*en/latest/scripting/(.+)/$ /scripting/$1.html;
    ~*en/latest/getting-started/(.+)/$ /getting-started/$1.html;
    ~*en/latest/editor/(.+)/$ /editor/$1.html;
    ~*en/latest/contributing/(.+)/$ /contributing/$1.html;

    #/rss/project_version/qownnotes.rss https://api.qownnotes.org/rss/app-releases;
}

server {
    listen 80;
    server_name qownnotes.org docs.qownnotes.org;
    return 301 https://www.qownnotes.org$request_uri;
}

server {
    listen 80;
    server_name localhost www.qownnotes.org;
    error_page 404 /404.html;

    if ( $redirect_uri ) {
        return 301 $redirect_uri;
    }

    location / {
        root   /usr/share/nginx/html;
        index  index.html;
    }

    location /api/ {
        proxy_pass http://qownnotes-api/api/;
    }

    location /rss/project_version/qownnotes.rss {
        proxy_pass http://qownnotes-api/rss/app-releases;
    }

#    location /rss {
#        proxy_pass http://old.qownnotes.org/rss;
#    }
}
