restic / rest-server

Rest Server is a high performance HTTP server that implements restic's REST backend API.
BSD 2-Clause "Simplified" License
922 stars 138 forks source link

Base URL flag #237

Open njenkins84 opened 1 year ago

njenkins84 commented 1 year ago

Output of rest-server --version

rest-server version rest-server 0.12.0 compiled with go1.20.3 on linux/amd64

What should rest-server do differently?

Would it be possible to add a base url flag? This way the base part of a request can be ignored, as it was used to route traffic to the server, not the user trying to make a request on the server.

What are you trying to do? What is your use case?

The rest-server is behind an Nginx proxied port. As configured the proxied port does not perform request matching on the base URL. Thus, the rest-server interprets incoming request from the user incorrectly, i.e. it see the request come in as "/base_path/user/..." rather then simply "/user/...".

Did rest-server help you today? Did it make you happy in any way?

The rest-server works great and am very happy with how it is performing!

wojas commented 1 year ago

You can rewrite the path in nginx with something like:

rewrite ^/base_path/(.*)$ /$1 break;
njenkins84 commented 1 year ago

The Nginx config is auto-generated such that the matching is not performed. I have full control over the Nginx config on my local development machine and can configure the URL matching easily

location /base_path/ {
    proxy_pass http://127.0.0.1:1234/;
}

The issue arose when configuring host for deployment which omits the trailing slashes, thus no URL matching occurs.

An alternative I'm also looking into would be to use rclone rather that rest-server to host the restic server as it appears to provide for configuring a base-url.