Skip to content

Commit

Permalink
proxy pass requests to static assets to gitlab unicorn
Browse files Browse the repository at this point in the history
When relative_url is in used, the links to assets in the
`application.css` file to not have the relative_url prefix. To fix this
we proxy pass asset requests to the upstream gitlab unicorn.

Fixes sameersbn#521
  • Loading branch information
Sameer Naik committed Dec 24, 2015
1 parent de94d95 commit cd18eb1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
33 changes: 33 additions & 0 deletions assets/runtime/config/nginx/gitlab
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
##
## See installation.md#using-https for additional HTTPS configuration details.

upstream gitlab {
server unix:{{GITLAB_INSTALL_DIR}}/tmp/sockets/gitlab.socket fail_timeout=0;
}

upstream gitlab-workhorse {
server unix:{{GITLAB_INSTALL_DIR}}/tmp/sockets/gitlab-workhorse.socket fail_timeout=0;
}
Expand Down Expand Up @@ -60,4 +64,33 @@ server {

proxy_pass http://gitlab-workhorse;
}

## If a static asset file is requested, then proxy passes the request to
## the upsteam (gitlab unicorn).
## As of 8.3.0 gitlab-workhorse does not properly generated the static assets
## when relative_url is used
location {{GITLAB_RELATIVE_URL_ROOT__with_trailing_slash}}assets {
try_files $uri /index.html $uri.html @gitlab;
}

location @gitlab {
## If you use HTTPS make sure you disable gzip compression
## to be safe against BREACH attack.
# gzip off;

## https://github.com/gitlabhq/gitlabhq/issues/694
## Some requests take more than 30 seconds.
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_buffering {{NGINX_PROXY_BUFFERING}};

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto {{NGINX_X_FORWARDED_PROTO}};
proxy_set_header X-Frame-Options SAMEORIGIN;

proxy_pass http://gitlab;
}
}
33 changes: 33 additions & 0 deletions assets/runtime/config/nginx/gitlab-ssl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
##
## See installation.md#using-https for additional HTTPS configuration details.

upstream gitlab {
server unix:{{GITLAB_INSTALL_DIR}}/tmp/sockets/gitlab.socket fail_timeout=0;
}

upstream gitlab-workhorse {
server unix:{{GITLAB_INSTALL_DIR}}/tmp/sockets/gitlab-workhorse.socket fail_timeout=0;
}
Expand Down Expand Up @@ -106,4 +110,33 @@ server {
proxy_set_header X-Forwarded-Proto {{NGINX_X_FORWARDED_PROTO}};
proxy_pass http://gitlab-workhorse;
}

## If a static asset file is requested, then proxy passes the request to
## the upsteam (gitlab unicorn).
## As of 8.3.0 gitlab-workhorse does not properly generated the static assets
## when relative_url is used
location {{GITLAB_RELATIVE_URL_ROOT__with_trailing_slash}}assets {
try_files $uri /index.html $uri.html @gitlab;
}

location @gitlab {
## If you use HTTPS make sure you disable gzip compression
## to be safe against BREACH attack.
# gzip off;

## https://github.com/gitlabhq/gitlabhq/issues/694
## Some requests take more than 30 seconds.
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_buffering {{NGINX_PROXY_BUFFERING}};

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto {{NGINX_X_FORWARDED_PROTO}};
proxy_set_header X-Frame-Options SAMEORIGIN;

proxy_pass http://gitlab;
}
}

0 comments on commit cd18eb1

Please sign in to comment.