Commit/Repository links are not working when repo name contains a slash (using Apache2 as reverse proxy)

Issue #87 closed
Niko Wittenbeck created an issue

Hi there,

I’ve started to use Jigit yesterday, thank you for that great plugin. During the setup phase, I’ve encountered an issue:

My repository (hosted on GitLab 12 CE) is located at https://server.com/devops/ansible, so the repository name is devops/ansible.

  1. Using “devops/ansible” as path does not allow me to test the connection nor to use the rest api because

‌ 400: https://server.com/api/v4/projects/devops%2Fansible/repository/branches/master . See JIRA log for details.

The slash is escaped, so the REST lookup does not work. Apart from that, the REST API only allows the project ID as identifier, manually assembling the unescaped REST URL returns 404. But using this pattern renders correct links in the activities (https://server.com/devops/ansible/commit… and https://server.com/devops/ansible)

2. Using the project ID (e.g. path=19) allows me to use the REST api and to get the activities correctly. But in this case, the activity links are not generated correctly as the links are generated like this: https://server.com/19/commit… and https://server.com/19/))

So the easiest approach would be to be able to define both ID and URL for link generation.

Thanks for feedback!

Comments (9)

  1. Dmitrii Apanasevich repo owner

    Hi Niko,

    It's not the add-on issue. I think, the root cause of the problem is nginx configuration. Look, at how other users solved the same issue:

  2. Niko Wittenbeck reporter

    Hi Dmitrii,

    thanks for the hint. We’re not using Nginx but Apache2 as reverse proxy and had a similar issues but solved these now. For future references, a collegue of mine will provide additional information to help other people that might have similar issues.

  3. Dmitrii Apanasevich repo owner

    Hi Niko,

    Thank you for letting me know the result.

    For future references, a collegue of mine will provide additional information to help other people that might have similar issues.

    That would be great!

  4. Luca Bernstein

    So in case anyone comes accross this problem in the future, this was our case:

    Our original Apache2 reverse proxy config for Git looked something like these. At some point we upgraded GitLab and the API changed from v3 to v4, which had been forgotten to adapt in the config. The affected (and important) parts in the config after the adaption are the following:

    <VirtualHost *:443>
      [...]
      AllowEncodedSlashes NoDecode
      [...]
      <Location />
        [...]
        ProxyPass http://127.0.0.1:8081/
        [...]
      </Location>
    
      RewriteEngine on
      RewriteCond %{REQUEST_URI} ^/api/v4/.*
      # In the following line, NE stands for "No Escape".
      RewriteRule .* http://127.0.0.1:8081%{REQUEST_URI} [P,QSA,NE]
    
      [...]
    </VirtualHost>
    

    Note the v4 API endpoint there, which has been changed. Likewise the NE was added to the rewrite rule.

    The problem without these configurations is that from the already escaped project URL the ampersand was escaped again.

  5. Log in to comment