twproxy icon indicating copy to clipboard operation
twproxy copied to clipboard

TW returning 403 on attempted save

Open kokestu opened this issue 4 years ago • 1 comments

Hey! Thanks for creating this auth proxy, it's exactly what I needed! Unfortunately, I'm having trouble setting it up.

I'm running a Apache2 server with a proxy to my Node TW and it's serving just fine on https://tiddly.mydomain.co.uk. I am able to set up the twproxy server just fine, and it displays the auth landing page, and creates the auth token as needed. However, once authentication is complete and the TW loads, the TW JS renders briefly before displaying a Sync error while processing '$:/StoryList'.

I had this issue before, when setting up the TW without twproxy, but I resolved it by allowing ecndoded slashes via my Apache config (following https://groups.google.com/forum/#!topic/tiddlywiki/sxU_TuUVRc8). Looking at the twproxy logs, I see 127.0.0.1 - - [15/Jun/2020:15:23:05 CEST] "PUT /recipes/default/tiddlers/$:/StoryList HTTP/1.1" 403 0, so I wondered if the twproxy server might be having similar problems. However, my ruby-fu is not good enough to debug the code effectively.

My command for starting TW server: tiddlywiki my-wiki --listen host=0.0.0.0 port=8081

twproxy logs:

root@vps:~# twproxy -u my-user -P <my-password-hash> -d http://0.0.0.0:8081/ -s
[2020-06-15 15:22:52] INFO  WEBrick 1.3.1
[2020-06-15 15:22:52] INFO  ruby 2.3.1 (2016-04-26) [x86_64-linux-gnu]
== Sinatra (v2.0.8.1) has taken the stage on 8888 for development with backup from WEBrick
[2020-06-15 15:22:52] INFO  WEBrick::HTTPServer#start: pid=28887 port=8888
127.0.0.1 - - [15/Jun/2020:15:22:57 CEST] "GET / HTTP/1.1" 200 17672970
- -> /
127.0.0.1 - - [15/Jun/2020:15:23:04 CEST] "GET /status HTTP/1.1" 200 109
https://tiddly.mydomain.co.uk/ -> /status
127.0.0.1 - - [15/Jun/2020:15:23:04 CEST] "OPTIONS / HTTP/1.1" 404 513
https://tiddly.mydomain.co.uk/ -> /
127.0.0.1 - - [15/Jun/2020:15:23:04 CEST] "HEAD / HTTP/1.1" 200 0
https://tiddly.mydomain.co.uk/ -> /
127.0.0.1 - - [15/Jun/2020:15:23:05 CEST] "PUT /recipes/default/tiddlers/$:/StoryList HTTP/1.1" 403 0
https://tiddly.mydomain.co.uk/ -> /recipes/default/tiddlers/$:/StoryList
127.0.0.1 - - [15/Jun/2020:15:23:05 CEST] "GET /recipes/default/tiddlers.json?filter=%5Ball%5Btiddlers%5D%5D%20-%5B%5B%24%3A%2FisEncrypted%5D%5D%20-%5Bprefix%5B%24%3A%2Ftemp%2F%5D%5D%20-%5Bprefix%5B%24%3A%2Fstatus%2F%5D%5D HTTP/1.1" 200 6730
https://tiddly.mydomain.co.uk/ -> /recipes/default/tiddlers.json?filter=%5Ball%5Btiddlers%5D%5D%20-%5B%5B%24%3A%2FisEncrypted%5D%5D%20-%5Bprefix%5B%24%3A%2Ftemp%2F%5D%5D%20-%5Bprefix%5B%24%3A%2Fstatus%2F%5D%5D
^C== Sinatra has ended his set (crowd applauds)
[2020-06-15 15:23:15] INFO  going to shutdown ...
[2020-06-15 15:23:15] INFO  WEBrick::HTTPServer#start done.

My Apache VirtualHost config:

root@vps565023:~# cat /etc/apache2/sites-available/tiddly.mydomain.co.uk.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>

        ServerAdmin [email protected]
        ServerName tiddly.mydomain.co.uk

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Include /etc/letsencrypt/options-ssl-apache.conf

        # # tiddlywiki proxy, via txproxy
        <Proxy *>
          Order Deny,Allow
          Allow from all
        </Proxy>

        RewriteEngine on
        RewriteCond %{HTTP:Upgrade} =websocket
        RewriteRule /(.*) ws://localhost:8888/$1 [P,L]
        RewriteCond %{HTTP:Upgrade} !=websocket
        RewriteRule /(.*) http://localhost:8888/$1 [P,L]
        ProxyPreserveHost On
        ProxyPass / http://0.0.0.0:8888
        ProxyPassReverse / http://0.0.0.0:8888
        AllowEncodedSlashes on
        SSLCertificateFile /etc/letsencrypt/live/tiddly.mydomain.co.uk/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/tiddly.mydomain.co.uk/privkey.pem
</VirtualHost>
</IfModule>

kokestu avatar Jun 15 '20 17:06 kokestu