ddvk / rmfakecloud

host your own cloud for the remarkable
GNU Affero General Public License v3.0
751 stars 61 forks source link

Reverse proxy through Apache2 #231

Closed giovi321 closed 1 year ago

giovi321 commented 1 year ago

Has anyone figured out how to configure a reverse proxy with Apache2? I get the following error:

l=warning msg="can't upgrade websocket to ws websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header"
l=info msg="[GIN] 2023/04/03 - 16:33:28 | 400 |     233.402<C2><B5>s |  192.168.56.105 | GET      \"/notifications/ws/json/1\""
l=info msg="Requested: notifications\n"
l=info msg="[GIN] 2023/04/03 - 16:34:06 | 200 |      78.414<C2><B5>s |  192.168.56.105 | GET      \"/service/json/1/notifications?environment=production&apiVer=1\""
giovi321 commented 1 year ago

Problem solved. It would be useful to add this to the documentation on the website. Here is my configuration for Apache2:

<VirtualHost *:80>
        ServerName remarkable.domain.com
        ServerAlias www.remarkable.domain.com
        RewriteEngine On
        RewriteCond %{HTTPS} !=on
        RewriteCond %{SERVER_NAME} =remarkable.domain.com
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>
        DocumentRoot /var/www/
        ServerName remarkable.domain.com
        ServerAlias www.remarkable.domain.com
        SSLEngine on
        ServerAdmin unavailable
        CustomLog ${APACHE_LOG_DIR}/vhosts/remarkable_access.log combined
        ErrorLog ${APACHE_LOG_DIR}/vhosts/remarkable_error.log
        <IfModule mod_headers.c>
            Header always add Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
        </IfModule>

        RewriteEngine On
        RewriteCond %{HTTP:Connection} Upgrade [NC]
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteRule /(.*) ws://rmfakecloud_ip/$1 [P,L]

        ProxyPass / http://rmfakecloud_ip/
        ProxyPassReverse / http://rmfakecloud_ip/
        ProxyRequests On
        ProxyPreserveHost On

        <Proxy *>
          Order Allow,Deny
          Allow from all
        </Proxy>

        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/remarkable.domain.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/remarkable.domain.com/privkey.pem
</VirtualHost>
giovi321 commented 1 year ago

Actually, it stopped working. I don't know how, but I managed to synchronize a document but now it doesn't work anymore.

giovi321 commented 1 year ago

Update: it works, but on the tablet it says connection failed. The files are being uploaded and downloaded.