Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit page link not working behind reverse proxy #310

Closed
djhworld opened this issue Dec 1, 2019 · 3 comments
Closed

Edit page link not working behind reverse proxy #310

djhworld opened this issue Dec 1, 2019 · 3 comments
Labels
pending Pending Close. Respond

Comments

@djhworld
Copy link

djhworld commented Dec 1, 2019

I'm running Raneto behind a reverse proxy.

This mostly works fine in terms of rendering notes properly, except when you open a note (e.g. data.md), and select Actions -> Edit you get directed to https://mydomain/data/edit instead of https://mydomain/notes/data/edit because it seems to ignore the base_url property I have configured

I've had a look at the template for the Edit link and it relies on this current_url property (https://github.com/gilbitron/Raneto/blob/master/themes/default/templates/page.html#L59) in https://github.com/gilbitron/Raneto/blob/master/app/routes/wildcard.route.js#L105

If I update this to

current_url   : req.protocol + '://' + req.get('host') + config.base_url + req.originalUrl,

It fixes the problem, but I'm not sure if that's the right way to go about it seeing as people might put FQDNs in the base_url

Setup I'm running

Relevant caddy section:

	proxy /notes pi3:8922 {
	    transparent
	    without /notes
	}

raneto config.js

base_url: '/notes'
@ryanlelek
Copy link
Owner

Yes, our test suite is currently lacking in how to test for all possible variants.
Your workaround is fine for now, let me open a PR and test with it.

In the future, we'll likely move to more isolated functions for URI calculation, auth permissions, etc.

ryanlelek added a commit that referenced this issue May 10, 2021
@ryanlelek
Copy link
Owner

Ok, your suggestion tested out fine in my quick checks.
I did change base_url from your suggestion to path_prefix
base_url is intended to be the FQDN as you pointed out.
There is now a path_prefix config variable to implement your fix.

And really, we should probably be using base_url to populate current_url variable, instead of assembling in-line.
Lots of PRs have been submitted (which is a great thing) and some cleanup is needed for consistency.

Here are the values I used in config.js:

base_url: 'http://local.raneto.com/raneto',
path_prefix: '/raneto',

Another important thing to note is Caddy is removing the path prefix, before proxying.
Not everyone may be removing the prefix, and we might need to support that as well.

For those that find this, here is the Nginx config used in testing for reference, because removing the path is complicated.

location ~ ^/raneto(/?)(.*) {
        proxy_pass        http://raneto/$2;
        proxy_redirect    off;
        proxy_set_header  Host $host;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
}

upstream raneto {
    server 127.0.0.1:3000 max_fails=10 fail_timeout=4s;
}

ryanlelek added a commit that referenced this issue May 10, 2021
@ryanlelek ryanlelek added the pending Pending Close. Respond label May 10, 2021
AnkushLambdatest pushed a commit to AnkushLambdatest/Raneto that referenced this issue Jun 29, 2022
AnkushLambdatest pushed a commit to AnkushLambdatest/Raneto that referenced this issue Jun 29, 2022
@ryanlelek
Copy link
Owner

@djhworld Thanks again for reporting.
Do you have any updates to share? Good, bad, etc?

I've moved this to the Roadmap so we can verify it.
Closing this issue (but you're welcome to re-open)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending Pending Close. Respond
Projects
None yet
Development

No branches or pull requests

2 participants