etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

Etherpad-lite version 2.2.2 doesn't work anymore with nginx subdirectory url configuration (unable to load indexBootstrap-XZV.min.js)

Open brknkfr opened this issue 1 year ago • 4 comments

Describe the bug I have serveral etherpad-lite instances. The main instance is under https://pad.domain.tld and there are other instances under https://pad.domain.tld/instance1/, https://pad.domain.tld/instance2/ and https://pad.domain.tld/instance3/. After upgrading to etherpad-lite version 2.2.2 only the main instance is still working, the subfolder instances fail to load indexBootstrap-XYZ.min.js. This is probably due to the javascript change in version 2.2.2. Please help.

  • Main instance: https://pad.domain.tld successfully loads indexBootstrap-MAIN.min.js from https://pad.domain.tld/indexBootstrap-MAIN.min.js
  • Subdirectory instance: As an example the instance under https://pad.domain.tld/instance/ tries to load indexBootstrap-OTHERINSTANCE.min.js from https://pad.domain.tld/indexBootstrap-OTHERINSTANCE.min.js (without instance subfolder path) which fails (HTTP error code 404). BUT the indexBootstrap-OTHERINSTANCE.min.js is reachable from https://pad.domain.tld/instance/indexBootstrap-OTHERINSTANCE.js (with subdirectory path /instance).

To Reproduce Steps to reproduce the behavior:

  1. Install a custom etherpad-lite instance on a subdirectory, for example https://pad.domain.tld/instance/
  2. Configure nginx to serve etherpad-lite from a subdirectory as described in https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy#from-subdirectory-url
  3. Try to use https://pad.domain.tld/instance/
  4. See that the instance failes to load https://pad.domain.tld/instance/ in the browser network console.

Expected behavior Version 2.2.2 should still work in subdirectory/subfolder installations.

Server (please complete the following information):

  • Etherpad version: 2.2.2
  • OS: Debian 12
  • Node.js version v18.19.0

Edit: Possibly related to https://github.com/ether/etherpad-lite/issues/6588, https://github.com/ether/etherpad-lite/issues/5359

brknkfr avatar Aug 17 '24 12:08 brknkfr

Feel free to try on develop. That should be fixed.

SamTV12345 avatar Aug 17 '24 19:08 SamTV12345

On a first try, applying https://github.com/ether/etherpad-lite/commit/3dae23a1e59f49939cdd73e3ffc9026f86045723 seems to help. I'll wait for the next release until I close the ticket. Apparently there are some plugins which do not work.

brknkfr avatar Aug 18 '24 14:08 brknkfr

On a first try, applying 3dae23a seems to help. I'll wait for the next release until I close the ticket. Apparently there are some plugins which do not work.

Thanks for the reply. Do you have any more plugins not working? If yes then just list them in a new issue and I'll fix them.

SamTV12345 avatar Aug 18 '24 17:08 SamTV12345

I have the same issue but using etherpad's Docker image instead of installing it myself.

Applying the above commit and then building the image didn't help.

n-goncalves avatar Aug 20 '24 13:08 n-goncalves

I still have the same error in the develop branch. If I open a pad in the develop branch, it only shows the loading screen. In the console it shows the error "https://xxx/padbootstrap-OwAkEXFiro8.min.js not found", https://xxx/etherpad/padbootstrap-OwAkEXFiro8.min.js exists.

JannesAlthoff avatar Aug 29 '24 07:08 JannesAlthoff

Current Setup:

  • Etherpad is running as a Docker service

  • Nginx is configured to proxy requests to Etherpad under a subfolder:

    ```
    location /etherpad/ {
    proxy_pass http://etherpad/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
    ```
    

The main Etherpad page seems to load, but it fails to fetch the padbootstrap-dWVv7D4yciw.min.js file, resulting in a 404 error.

Adz10kvtech avatar Aug 29 '24 13:08 Adz10kvtech

Could you send me the index.html script section please? It says for me which should always work as it goes 2 levels up the stack which should be the subfolder path. @Adz10kvtech

SamTV12345 avatar Aug 29 '24 16:08 SamTV12345

I also ran into this issue on master, but applying 3dae23a (and then rebuilding the assets) did not solve it for me either.

Can I provide anything in order to help debugging this?

level20peon avatar Sep 02 '24 07:09 level20peon

Try the develop image or the develop branch if you are working bare metal. @yacchin1205 had also a fix for the subdirectory problem.

SamTV12345 avatar Sep 02 '24 16:09 SamTV12345

Using the docker image etherpad:develop that was available 2 days ago, I was able to access pads when etherpad was configured to be served from a subdirectory however the /admin/plugins had still the same issueL

n-goncalves avatar Sep 05 '24 17:09 n-goncalves

Using the docker image etherpad:develop that was available 2 days ago, I was able to access pads when etherpad was configured to be served from a subdirectory however the /admin/plugins had still the same issueL

Did you apply the patches in https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy/ ? You need to set some headers in order to have the rooting correctly for the /admin/ endpoint.

SamTV12345 avatar Sep 05 '24 20:09 SamTV12345

It's still now working with version 2.2.4, now I get a different error.

ReferenceError: io is not defined
at https://pad.domain.tld/subdir/padbootstrap-5LZ5AmITgSI.min.js at line 72
ErrorId: pCIxHAKsfQtQntw7iiIo
Unhandled Promise rejection
URL: https://pad.domain.tld/subdir/p/testingpad
UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0

brknkfr avatar Sep 07 '24 15:09 brknkfr

It's still now working with version 2.2.4, now I get a different error.


ReferenceError: io is not defined

at https://pad.domain.tld/subdir/padbootstrap-5LZ5AmITgSI.min.js at line 72

ErrorId: pCIxHAKsfQtQntw7iiIo

Unhandled Promise rejection

URL: https://pad.domain.tld/subdir/p/testingpad

UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0

That sounds actually good. It means the JavaScript is executed but runs into an error. Do you use any plugins on your instance?

SamTV12345 avatar Sep 07 '24 15:09 SamTV12345

Ah, I see, without plugins, it works fine. It's ep_comments_page (version 1.0.36) which causes the error. I'll probably open another bug report.. See https://github.com/ether/ep_comments_page/issues/339

brknkfr avatar Sep 07 '24 16:09 brknkfr

Did you apply the patches in https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy/ ? You need to set some headers in order to have the rooting correctly for the /admin/ endpoint.

Sorry about the delay, I have read the wiki entry, I don't see anything really Etherpad specific to make it work behind a reverse proxy..

But the reverse proxy seems to be working as intended, the /admin/plugins pages returns a 200 status code with the below html.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Etherpad Admin Dashboard</title>
    <link rel="icon" href="/favicon.ico">
    <script type="module" crossorigin src="/admin/assets/index-a_6o1ecH.js"></script>
    <link rel="stylesheet" crossorigin href="/admin/assets/index-NApm68Ro.css">
  </head>
  <body>
    <div id="root"></div>
    <div id="loading"></div>
  </body>
</html>

As you can see, it tries to load the assets based on document root, which doesn't work if it's served from a from a subdirectory. Modifying those URLs directly in the container (/opt/etherpad-lite/src/templates/admin/index.html) allows the css to be fetched and the javascript to load, it later tries to fetch the fonts and translations, and that fails for the same reason.

By again editing the css and javascript manually, I was able to make those resources load as well, but the page is still blank, and it doesn't try to call /admin-auth as it is supposed to do. I assume other parts of the code assumes that everything is loaded from /admin .

n-goncalves avatar Sep 11 '24 13:09 n-goncalves

Did you apply the patches in https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy/ ? You need to set some headers in order to have the rooting correctly for the /admin/ endpoint.

Sorry about the delay, I have read the wiki entry, I don't see anything really Etherpad specific to make it work behind a reverse proxy..

But the reverse proxy seems to be working as intended, the /admin/plugins pages returns a 200 status code with the below html.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Etherpad Admin Dashboard</title>
    <link rel="icon" href="/favicon.ico">
    <script type="module" crossorigin src="/admin/assets/index-a_6o1ecH.js"></script>
    <link rel="stylesheet" crossorigin href="/admin/assets/index-NApm68Ro.css">
  </head>
  <body>
    <div id="root"></div>
    <div id="loading"></div>
  </body>
</html>

As you can see, it tries to load the assets based on document root, which doesn't work if it's served from a from a subdirectory. Modifying those URLs directly in the container (/opt/etherpad-lite/src/templates/admin/index.html) allows the css to be fetched and the javascript to load, it later tries to fetch the fonts and translations, and that fails for the same reason.

By again editing the css and javascript manually, I was able to make those resources load as well, but the page is still blank, and it doesn't try to call /admin-auth as it is supposed to do. I assume other parts of the code assumes that everything is loaded from /admin .

You need to set the Proxy Header var x-proxy-path to your subpath. Then it will work

SamTV12345 avatar Sep 24 '24 16:09 SamTV12345