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

Can't get it work with apache reverse proxy #194

Closed fuzunspm closed 2 years ago

fuzunspm commented 2 years ago

Output of rest-server --version

rest-server version rest-server 0.11.0 compiled with go1.13.8 on linux/amd64

How did you run rest-server exactly?

╰─$  sudo -u www-data ./rest-server --path /mnt/VAULT/restic --append-only --private-repos --listen "127.0.0.1:8001"
Data directory: /mnt/VAULT/restic
Authentication enabled
Loaded htpasswd file /mnt/VAULT/restic/.htpasswd
Private repositories enabled
start server on 127.0.0.1:8001

Expected behavior

Add repository from clients

Actual behavior

Clients can't add repository with an error message of:

╰─$ restic -r rest:https://user:pass@domain/user/ init
enter password for new repository:
enter password again:
Fatal: create repository at rest:https://user:pass@domain/user failed: Post "https://user:pass@domain/user/?create=true": dial tcp REMOTE_IP_ADDRESS:443: connect: connection refused

apache config

VirtualHost *:80>
    ServerName domain
    <Location />
        ProxyPass http://127.0.0.1:8001/
        ProxyPassReverse http://127.0.0.1:8001/
    </Location>
    ProxyPreserveHost On
    ProxyRequests Off
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName domain
    <Location />
        ProxyPass http://127.0.0.1:8000/
        ProxyPassReverse http://127.0.0.1:8000/
    </Location>
    ProxyPreserveHost On
    ProxyRequests Off

SSLCertificateFile /etc/letsencrypt/live/domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
MichaelEischer commented 2 years ago

dial tcp REMOTE_IP_ADDRESS:443: connect: connection refused

This shows that apache is not listening at port 443 or it is blocked by some firewall. Mostly likely, you forgot to enable mod_ssl or something else in the apache configuration is broken.