Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Added urlprefix for serving since I use a proxy and it seems useful#60

Merged
skx merged 1 commit intoskx:masterfrom
wetnun:master
Jun 18, 2019
Merged

Added urlprefix for serving since I use a proxy and it seems useful#60
skx merged 1 commit intoskx:masterfrom
wetnun:master

Conversation

@wetnun
Copy link
Contributor

@wetnun wetnun commented Jun 11, 2019

Has some hackiness in it, but can be used for reference if nothing else. I need to handle URI correctly because of my nginx proxy. Otherwise works great.

@skx
Copy link
Owner

skx commented Jun 12, 2019

This seems like you're running an nginx reverse proxy, and trying to allow it to work with a specific prefix.

So rather than:

You're expecting visitors to use:

Is that correct? So in your case you'd add /puppet-dashboard as the URL-prefix. (Or even the full http://blah.example.com/puppet-dashboard ).

If so I think this pull-request would solve the problem, but it is not the correct approach. I'd update the nginx configuration to handle the prefix. Something like:

server {
    listen 80 default;
    server_name blah.example.com;

    rewrite ^/puppet-dashboard(.*)$ /$1 break;

   location / {
       allow all;

          proxy_pass http://127.0.0.1:1243;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Scheme $scheme;
          proxy_connect_timeout 30;
          proxy_send_timeout 3600;
          proxy_read_timeout 3600;
          send_timeout 3600;
      }
  }

Am I missing something, or misunderstanding your use-case?

@wetnun
Copy link
Contributor Author

wetnun commented Jun 12, 2019

So I do use proxy_pass to get the service behind nginx (need port 443 and valid cert) under a /puppet prefix. The issue I ran into is that all of the links are hard coded to use / instead of a relative path. As a result the main report page works (minus the tablesort JS), but no links work inside of that without doing an html rewrite on the outbound html.

So example workflow from my running server:

  • load /puppet/ and see report page
  • click on $fqdn and html links to /puppet/node/$fqdn
  • nginx proxies that as /node/$fqdn to the Go service
  • service returns node view as expected

So it all work correctly because the html has the correct path for the proxy prefix.

@skx
Copy link
Owner

skx commented Jun 12, 2019

Now I understand, thank-you. I was going to suggest using relative-links instead, to avoid having to add a new configuration option, but it seems that gets annoying pretty quickly.

(i.e. I could change /report/123 to report/123, and similar for the node-view. But having the header link to / is a problem.)

I'll read your PR this evening/tomorrow and if there are no obviously problems I'll merge then.

Thanks for your explanation, and your contribution :)

@skx skx self-assigned this Jun 12, 2019
@skx
Copy link
Owner

skx commented Jun 18, 2019

This took longer than expected; but I'll merge now and cleanup soon.

Thanks again for your contribution :)

@skx skx merged commit 511076d into skx:master Jun 18, 2019
skx pushed a commit that referenced this pull request Jun 18, 2019
This fixes the links in the list, as well as the redirect target which
is used to reload the page.  This was missing from #60.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants