Skip to content
Snippets Groups Projects
Commit fe1bb890 authored by Christopher Zentgraf's avatar Christopher Zentgraf
Browse files

Fix URLs containing whitespace when GitLab used together with Apache

Turns off NoEscape flag. Adapted from https://gitlab.com/gitlab-org/gitlab-ce/issues/3163
parent 1e927428
No related branches found
No related tags found
1 merge request!47[Apache config] Fix URLs containing whitespace when GitLab used together with Apache
Loading
Loading
@@ -34,7 +34,7 @@
RewriteEngine on
 
#Forward all requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
 
# needed for downloading attachments
DocumentRoot /home/git/gitlab/public
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@
RewriteEngine on
 
#Forward all requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
 
# needed for downloading attachments
DocumentRoot /home/git/gitlab/public
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@
RewriteEngine on
 
#Forward all requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
 
# needed for downloading attachments
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
Loading
Loading
Loading
Loading
@@ -36,7 +36,7 @@
RewriteEngine on
 
#Forward these requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
 
# needed for downloading attachments
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
Loading
Loading
Loading
Loading
@@ -61,7 +61,7 @@
RewriteEngine on
 
#Forward all requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
 
RequestHeader set X_FORWARDED_PROTO 'https'
RequestHeader set X-Forwarded-Ssl on
Loading
Loading
Loading
Loading
@@ -62,7 +62,7 @@
RewriteEngine on
 
#Forward all requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
 
RequestHeader set X_FORWARDED_PROTO 'https'
RequestHeader set X-Forwarded-Ssl on
Loading
Loading
Loading
Loading
@@ -60,7 +60,7 @@
RewriteEngine on
 
#Forward all requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
 
RequestHeader set X_FORWARDED_PROTO 'https'
RequestHeader set X-Forwarded-Ssl on
Loading
Loading
Loading
Loading
@@ -61,7 +61,7 @@
RewriteEngine on
 
#Forward all requests to gitlab-workhorse
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
 
RequestHeader set X_FORWARDED_PROTO 'https'
RequestHeader set X-Forwarded-Ssl on
Loading
Loading
  • Removing the NE (No Escape ) flag from RewriteRule breaks accessing projects with the GitLab API via NAMESPACE/PROJECT_NAME. For example, now the request /api/v3/projects/foo%2Fbar/repository/branches will be forwarded to /api/v3/projects/foo%252Fbar/repository/branches -- it will percent encode the percent encode. See https://gitlab.com/gitlab-org/gitlab-recipes/commit/e44ea041dde57b5075f738046ec6316613cb790a

  • cc @Zenti

  • I'm currently adding another rule for api requests where the NE flag is set, as well as fixing error documents not displaying (see #43 (closed)). Will add a merge request soon.

  • Are there other URLs containing percent encoded characters other than the api?

  • username-removed-17194 @Zenti

    mentioned in merge request !52 (merged)

    ·

    mentioned in merge request !52 (merged)

    Toggle commit list
  • Are there other URLs containing percent encoded characters other than the api?

    @jacobvosmaer @ayufan do you have any idea?

  • @andy_schmidt can you try with the latest config?

  • @axil can't think of any right now.

  • @axil this fixes my API issue... thanks for the fast response, much appreciated! (Though I haven't tried out file uploads)

  • It does not work with my url. Im using apache 2.4 with the latest gitlab-omnibus-ssl-apache24.conf config

    Here is an example: https://git.example.com/User/example/tree/master/test%20folder

  • I can verify your problem on a second GitLab instance I have recently set up, but not in my primary GitLab instance.

    I found a solution for my second GitLab instance. In your gitlab-omnibus-ssl-apache24.conf file, can you replace the line

    RewriteCond %{REQUEST_URI} ^/api/v3/.* [OR]

    with

    RewriteCond %{REQUEST_URI} ^/api/v3/.*

    and try again?

    Please report back whether that fixes your problem. If it does, I will submit it as a MR.

    Edited by username-removed-17194
  • It works with RewriteCond {REQUEST_URI} ^/api/v3/.*

    Thank you for your quick response.

  • No Problem. I will submit this fix as a MR.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment