davideuler / gitblit

Automatically exported from code.google.com/p/gitblit
Apache License 2.0
0 stars 0 forks source link

graph images are hard coded and do not view with mod_proxy #559

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by D.H.Bo...@gmail.com on 3 Feb 2015 at 12:24

GoogleCodeExporter commented 9 years ago
Sorry, should add, the url is hard coded with the glassfish host and ip address

Original comment by D.H.Bo...@gmail.com on 3 Feb 2015 at 12:25

GoogleCodeExporter commented 9 years ago
Can't you use mod_rewrite here too?

Original comment by James.Mo...@gmail.com on 3 Feb 2015 at 12:45

GoogleCodeExporter commented 9 years ago
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>

Original comment by D.H.Bo...@gmail.com on 4 Feb 2015 at 9:10

GoogleCodeExporter commented 9 years ago
Your suspicions are confirmed, it does hard-code an url.

Original comment by James.Mo...@gmail.com on 4 Feb 2015 at 12:53

GoogleCodeExporter commented 9 years ago
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

Original comment by D.H.Bo...@gmail.com on 11 Feb 2015 at 7:30