question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

We have a main domain http://domain.com/ which is serving up our main document.

We have added a proxy route (AWS ALB) to serve Raneto from https://domain.com/docs/

We have changed “base_url” to “/docs”, but nothing is served from there.

Logs show the following:

0|server   | GET /docs/ 404 4.870 ms - 2180
0|server   | GET /docs/lib/bootstrap/dist/css/bootstrap.min.css 304 2.712 ms - -
0|server   | GET /docs/lib/highlightjs/styles/solarized_light.css 304 1.680 ms - -
0|server   | GET /docs/styles/raneto.css 304 4.797 ms - -
0|server   | GET /docs/styles/ghostdown.css 304 5.429 ms - -
0|server   | GET /docs/lib/jquery/dist/jquery.min.js 304 8.428 ms - -
0|server   | GET /docs/lib/bootstrap/dist/js/bootstrap.min.js 304 9.149 ms - -
0|server   | GET /docs/lib/highlightjs/highlight.pack.min.js 304 9.042 ms - -
0|server   | GET /docs/lib/fitvids/fitvids.min.js 304 8.891 ms - -
0|server   | GET /docs/lib/masonry-layout/dist/masonry.pkgd.min.js 304 9.202 ms - -
0|server   | GET /docs/scripts/ghostdown.js 304 7.922 ms - -
0|server   | GET /docs/scripts/raneto.js 304 8.475 ms - -

We basically want the index of the knowledgebase to be served from “/docs/”, not from “/”. Is this possible without modifying the application code? The load balancer does not have the option to proxy relative paths, from my understanding.

The other alternative is to put another loadbalancer (nginx) on top of this to forward requests and alter the incoming path (from “/docs/" to "/”), but this is overkill in my opinion. We would possibly need to do a subdomain otherwise, which we’re not excited about.

Interested in hearing your ideas. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
drj-iocommented, Mar 27, 2017

I have mostly fixed this by editing app/index.js and using the express-urlrewrite middleware: https://github.com/kapouer/express-urlrewrite

And also moved public theme assets to themes/default/public/docs

Here’s what I did:

  • npm install express-urlrewrite
  • add property to the config: rewrite_prefix: '/docs',
  • bring in the dependency to app/index.js -> var rewrite = require("express-urlrewrite");
  • use the middleware: app.use(rewrite(config.rewrite_prefix + '/*','/$1'));

This takes care of most of the static routes that our users will need. It appears, however, that the login features are now broken, and who knows about the editing capability.

If this is something you guys would like to iterate with me on, I can submit a PR. Or if there’s a better way, let me know… Thanks.

EDIT:

Fixed the style issues on the login page by adding config to the route:

'use strict';

function route_login_page (config) {
  return function (req, res, next) {

    return res.render('login', {
      config      : config,
      layout      : null,
      lang        : config.lang,
      rtl_layout  : config.rtl_layout,
      googleoauth : config.googleoauth
    });

  };
}

// Exports
module.exports = route_login_page;

There are still issues with static assets. I had to move themes/default/public to themes/default/public/docs to make that work, but the URLs are hard coded in the client side JS, so I’d have to change that too.

0reactions
ryanlelekcommented, Jan 4, 2020

Please see this branch/PR to address your issue and confirm/deny the fix. https://github.com/gilbitron/Raneto/pull/312

Read more comments on GitHub >

github_iconTop Results From Across the Web

Restructuring a monolith 101: Nginx proxy by subfolder
Its really a very simple issue. When you attempt delegating the work of a single orthodox monolith, without downtime and greenfield approach ...
Read more >
nginx proxy_pass using subfolder - reverse proxy - Server Fault
I would like to have a subfolder after my domain name (actually after the IP of that domain name), which redirects to a...
Read more >
The "subfolder problem", OR, "why can't I reverse proxy my ...
Have you ever tried to reverse proxy an app into its own little subfolder of your domain name? Makes things neat, doesn't it?...
Read more >
HOW TO: Use Cloudflare to reverse proxy a subdirectory
You have a requirement to serve a complete site through a "subdirectory" (ie. /news or /blog) without being able to move it "physically"...
Read more >
Support for subfolders in proxy hosts · Issue #40 - GitHub
Currently, a proxy host is hard-coded to the / (root) location. In addition to this, it would be very useful to support multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found