linuxserver / docker-calibre

GNU General Public License v3.0
339 stars 62 forks source link

Add Base URL for Reverse Proxy Subfolder Support #52

Closed CrypticOne closed 3 years ago

CrypticOne commented 3 years ago

linuxserver.io


Desired Behavior

  1. Pass base URL to docker container -> guacamole
  2. Setup Reverse Proxy to load web interface on www.somedomain.com/calibre/
  3. Interface Loads correctly on both 192.168.0.100:8080/calibre and www.somedomain.com/calibre/

Current Behavior

  1. Interface Loads correctly when using 192.168.0.100:8080/
  2. Interface fails to load when using www.somedomain.com/calibre/. Source shows site trying to access files in /public/ directory which does not exist. IE: /public/vendor/guac/js/guac.min.js

Alternatives Considered

github-actions[bot] commented 3 years ago

Thanks for opening your first issue here! Be sure to follow the bug or feature issue templates!

CrypticOne commented 3 years ago

https://github.com/linuxserver/docker-baseimage-rdesktop-web/issues/3

Issue on the upstream package.

CrypticOne commented 3 years ago

I managed to hack up a solution. The issue seems to start in the gclient package. @thelamer

https://github.com/linuxserver/gclient/blob/6772097d74ce00aefa94953fe74e0bd470486ca2/rdp.ejs#L78

I edited all the references to /public/ and /files/ to just be public/ and files/

Now it loads when connected directly or via reverse proxy.

`

<script type="text/javascript" src="public/vendor/guac/js/guac.min.js"></script>
<!-- Helpers -->
<script type="text/javascript" src="public/vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="public/vendor/popper/popper.min.js"></script>
<script type="text/javascript" src="public/vendor/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="public/vendor/shortcut/js/shortcut.js"></script>
<!-- Client side -->
<script type="text/javascript" src="public/js/rdp.js"></script>

`

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

aptalca commented 3 years ago

https://github.com/linuxserver/reverse-proxy-confs/blob/master/calibre.subfolder.conf.sample#L2

rbrussell82 commented 2 years ago

I tried adding the SUBFOLDER=/calibre/ Docker environment variable and the interface still fails to load when going to www.somedomain.com/calibre/ but works when going to my local IP and port like 192.168.0.100:8080/calibre/.

aptalca commented 2 years ago

Did you update your proxy conf?

rbrussell82 commented 2 years ago

Did you update your proxy conf?

Yes, I replaced my original one with the current sample that has the comment about the environment variable. I get a blank white page that only shows the arrow on the left for the clipboard options.

aptalca commented 2 years ago

Check your browser plugins, disable to try (can also try incognito)

rbrussell82 commented 2 years ago

Tried different browsers and incognito, same experience. The black mouse pointer disappears almost right away. Is there another way to set the base URL or is that what the environment variable does?

aptalca commented 2 years ago

Your base url is working as confirmed by going to the local ip with that base url

CrypticOne commented 2 years ago

Can you view source on the somedomain.com/calibre and see if it is trying to access any "/public" files?

I haven't tested the fix @aptalca put into place yet.

rbrussell82 commented 2 years ago

I can see that it is trying /calibre/public.

<html>
<body>
<!--StartFragment-->

<title>Guacamole Client</title>
--
  | <link href="/calibre/public/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  | <link href="/calibre/public/vendor/font-awesome/css/fontawesome.min.css" rel="stylesheet" type="text/css">
  | <link href="/calibre/public/css/vdi.css" rel="stylesheet" type="text/css">
  | <link rel="apple-touch-icon" sizes="57x57" href="/calibre/public/favicon/apple-icon-57x57.png">
  | <link rel="apple-touch-icon" sizes="60x60" href="/calibre/public/favicon/apple-icon-60x60.png">
  | <link rel="apple-touch-icon" sizes="72x72" href="/calibre/public/favicon/apple-icon-72x72.png">
  | <link rel="apple-touch-icon" sizes="76x76" href="/calibre/public/favicon/apple-icon-76x76.png">
  | <link rel="apple-touch-icon" sizes="114x114" href="/calibre/public/favicon/apple-icon-114x114.png">
  | <link rel="apple-touch-icon" sizes="120x120" href="/calibre/public/favicon/apple-icon-120x120.png">
  | <link rel="apple-touch-icon" sizes="144x144" href="/calibre/public/favicon/apple-icon-144x144.png">
  | <link rel="apple-touch-icon" sizes="152x152" href="/calibre/public/favicon/apple-icon-152x152.png">
  | <link rel="apple-touch-icon" sizes="180x180" href="/calibre/public/favicon/apple-icon-180x180.png">
  | <link rel="icon" type="image/png" sizes="192x192"  href="/calibre/public/favicon/android-icon-192x192.png">
  | <link rel="icon" type="image/png" sizes="32x32" href="/calibre/public/favicon/favicon-32x32.png">
  | <link rel="icon" type="image/png" sizes="96x96" href="/calibre/public/favicon/favicon-96x96.png">
  | <link rel="icon" type="image/png" sizes="16x16" href="/calibre/public/favicon/favicon-16x16.png">
  | <link rel="manifest" href="/calibre/public/favicon/manifest.json">
  | <meta name="msapplication-TileColor" content="#ffffff">
  | <meta name="msapplication-TileImage" content="/calibre/public/favicon/ms-icon-144x144.png">
  | <meta name="theme-color" content="#ffffff">

<!--EndFragment-->
</body>
</html>

And I can also see the baseurl setting:

<html>
<body>
<!--StartFragment-->

<!-- Storage for encoded connection string and baseurl -->
--
  | <input type="hidden" id="connectionstring" value="xxxx" />
  | <input type="hidden" id="baseurl" value="/calibre/" />
  | <!-- Guacamole -->
  | <script type="text/javascript" src="/calibre/public/vendor/guac/js/guac.min.js"></script>
  | <!-- Helpers -->
  | <script type="text/javascript" src="/calibre/public/vendor/jquery/jquery.min.js"></script>
  | <script type="text/javascript" src="/calibre/public/vendor/popper/popper.min.js"></script>
  | <script type="text/javascript" src="/calibre/public/vendor/bootstrap/js/bootstrap.min.js"></script>
  | <script type="text/javascript" src="/calibre/public/vendor/shortcut/js/shortcut.js"></script>
  | <!-- Client side -->
  | <script type="text/javascript" src="/calibre/public/js/rdp.js"></script>

<!--EndFragment-->
</body>
</html>
CrypticOne commented 2 years ago

Looks pretty good. Odd it isn't loading.

thelamer commented 2 years ago

Post any errors in your browsers console when this occurs.

rbrussell82 commented 2 years ago

Here's what console shows when it stops:

WebSocket connection to 'wss://myurl.com/calibre/guaclite?token=eyJpdiI6IjNqbktlYy9SNnA4VEhiRUgxTVdSMXc9PSIsInZhbHVlIjoiVit6Wm9CbDVvRGxZRjNiRUV1VnJCYUVEN0QwS3J3WW13WFB5OTdpZEc2bEhOSmd4VmdWUjU5VmpCRy9ESHJzcnN2bTh1NzZpc0tNcGp5MXk1V0RzSzJEajBmL2FyTldaS3hUSEVZLzRNMytQeGt3YVdaM0pjWEZjeHNNZUd0VVBOc3NmT2pDdjA3cUFpRU01NkFYblVZN0VqVG12RDJ1NEJiclkxYjFtZEVPUW43WnVmY0RMbVdrY2dUbDlhL0ttaG5IOUV1YXN0enIwT3AwZTNuSlFlT0lTVDRjRmQ2N1QzMjhFcnMvYnlkVT0ifQ==&width=1407&height=1297?undefined' failed: 
connect @ guac.min.js:1
connect @ guac.min.js:1
(anonymous) @ rdp.js:90
thelamer commented 2 years ago

The path is correct so it would indicate that your proxy is not upgrading websocket requests properly.

rbrussell82 commented 2 years ago

The path is correct so it would indicate that your proxy is not upgrading websocket requests properly.

That pointed me in the right direction and maybe this will help someone else. I had to add these into my calibre.subfolder.conf file and now it works:

    proxy_set_header Connection "Upgrade";
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Host $host;
aptalca commented 2 years ago

Those are handled in the nginx.conf Likely your config files are out of date. The log should tell you if they are