You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup_proxy.mkd 3.3KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ## Running Gitblit behind Apache
  2. Gitblit runs fine behind Apache.
  3. Each Linux distribution may vary on the exact configuration of Apache 2.2.
  4. Here is a sample configuration that works on Debian 7.0 (Wheezy), your distribution may be different.
  5. ### Make sure we have Apache's proxy modules
  6. ```
  7. sudo su
  8. cd /etc/apache2/mods-enabled
  9. ln -s ../mods-available/proxy.load proxy.load
  10. ln -s ../mods-available/proxy_balancer.load proxy_balancer.load
  11. ln -s ../mods-available/proxy_http.load proxy_http.load
  12. ```
  13. ### Configuring Apache to use the proxy modules
  14. Now we must configure Apache to use the proxy modules and the proxied connection from Apache to Gitblit GO or from Apache to your chosen servlet container. The following snippet is stored as `/etc/apache2/conf.d/gitblit`.
  15. ```
  16. # Turn off support for true Proxy behaviour as we are acting as
  17. # a transparent proxy
  18. ProxyRequests Off
  19. # Turn off VIA header as we know where the requests are proxied
  20. ProxyVia Off
  21. # Turn on Host header preservation so that the servlet container
  22. # can write links with the correct host and rewriting can be avoided.
  23. #
  24. # This is important for all git push/pull/clone operations.
  25. ProxyPreserveHost On
  26. # Set the permissions for the proxy
  27. <Proxy>
  28. AddDefaultCharset off
  29. Order deny,allow
  30. Allow from all
  31. </Proxy>
  32. # The proxy context path must match the Gitblit context path.
  33. # For Gitblit GO, see server.contextPath in gitblit.properties.
  34. #ProxyPass /gitblit http://localhost:8080/gitblit
  35. #ProxyPassreverse /gitblit http://localhost:8080/gitblit
  36. # If your httpd frontend is https but you are proxying http Gitblit WAR or GO
  37. #Header edit Location ^http://([^/]+)/gitblit/ https://$1/gitblit/
  38. # Additionally you will want to tell Gitblit the original scheme and port
  39. #RequestHeader set X-Forwarded-Proto https
  40. #RequestHeader set X-Forwarded-Port 443
  41. # If you are using subdomain proxying then you will want to tell Gitblit the appropriate
  42. # context path for your repository url.
  43. # If you are not using subdomain proxying, then ignore this setting.
  44. #RequestHeader set X-Forwarded-Context /
  45. ```
  46. **Please** make sure to:
  47. 1. Review the security of these settings as appropriate for your deployment
  48. 2. Uncomment the *ProxyPass* setting
  49. 3. Correctly set the ports and context paths both in the *ProxyPass* definition and your Gitblit installation
  50. 4. Set *web.mountParameters=false* in `gitblit.properties` or `web.xml` this will use parameterized URLs.
  51. Alternatively, you can respecify *web.forwardSlashCharacter*.
  52. ### Controlling Advertised Repository URLs
  53. In some reverse-proxy configurations you may be running Gitblit using an http interface with an https reverse-proxy proxy. This will lead to Gitblit generating incorrect repository urls.
  54. You can control the url that Gitblit generates by setting X-Forwarded headers in your proxy server.
  55. *X-Forwarded-Proto*://servername(:*X-Forwarded-Port*)(/*X-Forwarded-Context*)
  56. ---X:MEDIAWIKI---
  57. {| class="table table-bordered"
  58. ! Header
  59. ! Description
  60. |-
  61. | X-Forwarded-Port
  62. | The port to use in generated repository http/https urls
  63. |-
  64. | X-Forwarded-Proto
  65. | The protocol/scheme to use in generated repository http/https urls
  66. |-
  67. | X-Forwarded-Context
  68. | The context to use in generated repository http/https urls
  69. |}
  70. ---X:MEDIAWIKI---