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

Jekyll url is not applied to the View button #610

Open
melroy89 opened this issue Nov 19, 2020 · 11 comments · May be fixed by #684
Open

Jekyll url is not applied to the View button #610

melroy89 opened this issue Nov 19, 2020 · 11 comments · May be fixed by #684

Comments

@melroy89
Copy link

melroy89 commented Nov 19, 2020

Description:

Pressing the View button in the admin panel the URL is pointing to http://localhost:4000. But I'm behind a reverse proxy called Nginx.

Tell us a bit about yourself:

  • Version of JekyllAdmin I'm using: 0.10.2
  • Version of Jekyll I'm using: 4.1.1
  • Version of NodeJS I'm using: v14.15.0
  • Operating System <e.g. OS X, Windows>: Linux!
  • Browser <e.g, Safari, Chrome>: Firefox!

Steps to reproduce:

  1. Setup Jekyll as normal
  2. Configure _config.yml file, and set url key to: url: "https://yourdomain.com" (baseurl is just "/")
  3. Configure Nginx to use yourdomain.com as server_name in Nginx with a location / section containing at least: proxy_pass http://localhost:4000;
  4. Go to admin panel: https://yourdomain.com/admin
  5. Press the View button
  6. Links goes to http://localhost:4000/jekyll/update/2020/11/19/welcome-to-jekyll.html, which will NOT work.

I expected the following:

I expect the View links to take the url settings into account. The link example above, should go to:

https://yourdomain.nl/jekyll/update/2020/11/19/welcome-to-jekyll.html

But got the following, instead:

http://localhost:4000/jekyll/update/2020/11/19/welcome-to-jekyll.html

I think it shouldn't be that hard to get this solved, I hope 👍🏽 ?

Regards,
Melroy van den Berg

@melroy89 melroy89 changed the title Jekyll url is not applied in View button Jekyll url is not applied to the View button Nov 19, 2020
@i-a-n
Copy link
Contributor

i-a-n commented Nov 25, 2020

this has been brought up a few times I believe, and I have yet to see an official response. I was able to get this working on my personal fork, however I do not believe my method (hijacking the URLable library to look for a special Jekyll config param) is necessarily a good answer for this project.

you can see my personal hack at this commit:

lib/jekyll-admin/urlable.rb
    def scheme
      JekyllAdmin.site.config["static_scheme"] || "http"
    end

    def host
      JekyllAdmin.site.config["static_host"] || JekyllAdmin.site.config["host"].sub("127.0.0.1", "localhost")
    end

    def port
      JekyllAdmin.site.config["static_port"] || JekyllAdmin.site.config["port"]
    end

... then on my Jekyll install:

_config.yml
static_scheme: https
static_host: [my domain name]
static_port: "443"

this got things working for me 👍

@melroy89
Copy link
Author

melroy89 commented Nov 26, 2020

Wow, indeed this should become a PR. This is indeed working as expected.

For backwards compatibility change:

JekyllAdmin.site.config["static_scheme"] || "http"

To:

JekyllAdmin.site.config["static_scheme"] || JekyllAdmin.site.config["scheme"] || "http"

Thank you so much! Let's fix this once and forever people!

Ps. Also in YML this is just fine: static_port: 443 (no additional quotes are needed)

@mertkahyaoglu
Copy link
Member

@i-a-n Thanks for the suggested solution. @ashmaroli Would you approve this?

@ashmaroli
Copy link
Member

Would you approve this?

I would approve a tested Pull Request that proposes use of JekyllAdmin.site.config["jekyll_admin"][key] instead.

@jekyllbot
Copy link

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

@melroy89
Copy link
Author

I hope you get a reply so it can be merged.

@jekyllbot jekyllbot removed the stale label Mar 23, 2021
@jekyllbot
Copy link

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

@derek-adair
Copy link

I would approve a tested Pull Request that proposes use of JekyllAdmin.site.config["jekyll_admin"][key] instead.

Can you clarify this? I'm running jekyll-admin behind a reverse-proxy and would love to get this in there. I think you are suggesting we have a setting that... if present will override the jekyll host config? Seems reasonable to me.

@melroy89
Copy link
Author

It's a two year old issue. But as stated in my first issue description the website url is not being when indeed behind a reverse proxy (nginx). Causing those links not to work since they are pointing to local host with custom port. Instead of the domain name.

@derek-adair
Copy link

No, i get your issue @Danger89... :) I would like this feature as well. My question for clarification was for @ashmaroli, as in what will it take to merge this pull request.

@melroy89
Copy link
Author

Ow sorry my bad!

@ashmaroli Your turn xD

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

Successfully merging a pull request may close this issue.

6 participants