gitblit icon indicating copy to clipboard operation
gitblit copied to clipboard

graph images are hard coded and do not view with mod_proxy

Open gitblit opened this issue 9 years ago • 5 comments

Originally reported on Google Code with ID 559

What steps will reproduce the problem?
1.Install war on Glassfish
2.mod_proxy reverse proxy
3.context_path -> gitblit
4. when viewing repository:summary the graph does not appear.  

What is the expected output? What do you see instead?
I expect to see the commit graph
I see a broken image link


What version of the product are you using? On what operating system?
v1.6.2
Suse server : multiple browsers on multiple os


Please provide any additional information below.
Inspecting the image shows that the servlet has hard coded the url to the glassfish
server and does not use a relative path. Hence the reverse proxy can do nothing about
it beacause the web page is served up with a link which it can not access.

Reported by D.H.Bowes on 2015-02-03 12:24:17

gitblit avatar Aug 12 '15 12:08 gitblit

Sorry, should add, the url is hard coded with the glassfish host and ip address

Reported by D.H.Bowes on 2015-02-03 12:25:46

gitblit avatar Aug 12 '15 12:08 gitblit

Can't you use mod_rewrite here too?

Reported by James.Moger on 2015-02-03 12:45:32

gitblit avatar Aug 12 '15 12:08 gitblit

When the page is written, the host is hard coded in the img url .  mod_rewrite does
not see the content of the page being delivered, just the place where the file is going
to /coming from.

My suspicion is that BranchGraphServlet.java is hard coding the img url:

<code>
public static String asLink(String baseURL, String repository, String objectId, int
numberCommits) {
        if (baseURL.length() > 0 && baseURL.charAt(baseURL.length() - 1) == '/') {
            baseURL = baseURL.substring(0, baseURL.length() - 1);
        }
        return baseURL + Constants.BRANCH_GRAPH_PATH + "?r=" + repository
                + (objectId == null ? "" : ("&h=" + objectId))
                + (numberCommits > 0 ? ("&l=" + numberCommits) : "");
    }
</code>

Reported by D.H.Bowes on 2015-02-04 09:10:26

gitblit avatar Aug 12 '15 12:08 gitblit

Your suspicions are confirmed, it does hard-code an url.

Reported by James.Moger on 2015-02-04 12:53:58

gitblit avatar Aug 12 '15 12:08 gitblit

work around:
a2enmod mod_substitute

add the location tag which does the proxying
<location /gitblit>
   ProxyPass http://127.0.0.1:8080/gitblit
   ProxyPassReverse http://127.0.0.1:8080/gitblit
   AddOutputFilterByType SUBSTITUTE text/html
   Substitute "s|http://127.0.0.1:8080/|http://<YOUR SERVER HOST>/|i"
</location>

NB change <Your SERVER HOST> to the host name of the world facing server
AND restart apache


Reported by D.H.Bowes on 2015-02-11 19:30:01

gitblit avatar Aug 12 '15 12:08 gitblit