blob: 563b322b544e7fef7cb6e3598874f9b341fd3b46 [file] [log] [blame]
Francois Marierd550b462011-04-13 14:30:20 +12001Gerrit Code Review - Reverse Proxy
2==================================
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -08003
4Description
5-----------
6
Francois Marier624f4472011-04-13 15:58:14 +12007Gerrit can be configured to run behind a third-party web server.
David Pursehouse221d4f62012-06-08 17:38:08 +09008This allows the other web server to bind to the privileged port 80
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -08009(or 443 for SSL), as well as offloads the SSL processing overhead
10from Java to optimized native C code.
11
12
Francois Marier624f4472011-04-13 15:58:14 +120013Gerrit Configuration
14--------------------
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080015
16Ensure `'$site_path'/etc/gerrit.config` has the property
17link:config-gerrit.html#httpd.listenUrl[httpd.listenUrl] configured
18to use 'proxy-http://' or 'proxy-https://' and a free port number.
19This may have already been configured if proxy support was enabled
20during 'init'.
21
22----
23 [httpd]
24 listenUrl = proxy-http://127.0.0.1:8081/r/
25----
26
Francois Marier624f4472011-04-13 15:58:14 +120027
28Apache 2 Configuration
29----------------------
30
Steffen Gebert832014f2013-06-03 21:42:47 +020031To run Gerrit behind an Apache server using 'mod_proxy', enable the
Francois Marier624f4472011-04-13 15:58:14 +120032necessary Apache2 modules:
33
34----
Steffen Gebert832014f2013-06-03 21:42:47 +020035 a2enmod proxy_http
Francois Marier624f4472011-04-13 15:58:14 +120036 a2enmod ssl ; # optional, needed for HTTPS / SSL
37----
38
Steffen Gebert832014f2013-06-03 21:42:47 +020039Configure an Apache VirtualHost to proxy to the Gerrit daemon,
40setting the 'ProxyPass' line to use the 'http://' URL configured
41above. Ensure the path of ProxyPass and httpd.listenUrl match,
42or links will redirect to incorrect locations.
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080043
44----
45 <VirtualHost *>
46 ServerName review.example.com
47
Steffen Gebert832014f2013-06-03 21:42:47 +020048 ProxyRequests Off
49 ProxyVia Off
50 ProxyPreserveHost On
51
52 <Proxy *>
53 Order deny,allow
54 Allow from all
55 </Proxy>
56
57 AllowEncodedSlashes On
58 ProxyPass /r/ http://127.0.0.1:8081/r/ nocanon
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080059 </VirtualHost>
60----
61
Steffen Gebert832014f2013-06-03 21:42:47 +020062The two options 'AllowEncodedSlashes On' and 'ProxyPass .. nocanon' are required
63since Gerrit 2.6.
64
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -080065SSL
66~~~
67
68To enable Apache to perform the SSL processing, use 'proxy-https://'
69in httpd.listenUrl within Gerrit's configuration file, and enable
70the SSL engine in the Apache VirtualHost block:
71
72----
73 <VirtualHost *:443>
74 SSLEngine on
75 SSLCertificateFile conf/server.crt
76 SSLCertificateKeyFile conf/server.key
77
78 ... same as above ...
79 </VirtualHost>
80----
81
82See the Apache 'mod_ssl' documentation for more details on how to
83configure SSL within the server, like controlling how strong of an
84encryption algorithm is required.
85
Steffen Gebert832014f2013-06-03 21:42:47 +020086Troubleshooting
87~~~~~~~~~~~~~~~
88
89If you are encountering 'Page Not Found' errors when opening the change
90screen, your Apache proxy is very likely decoding the passed URL.
91Make sure to either use 'AllowEncodedSlashes On' together with
92'ProxyPass .. nodecode' or alternatively a 'mod_rewrite' configuration with
93'AllowEncodedSlashes NoDecode' set.
94
Francois Marier624f4472011-04-13 15:58:14 +120095
96Nginx Configuration
97-------------------
98
99To run Gerrit behind an Nginx server, use a server statement such
100as this one:
101
102----
103 server {
104 listen 80;
Piotr Sikora2e6a4ae2011-04-13 17:11:18 +0000105 server_name review.example.com;
Francois Marier624f4472011-04-13 15:58:14 +1200106
107 location /r/ {
Piotr Sikora2e6a4ae2011-04-13 17:11:18 +0000108 proxy_pass http://127.0.0.1:8081;
109 proxy_set_header X-Forwarded-For $remote_addr;
110 proxy_set_header Host $host;
Francois Marier624f4472011-04-13 15:58:14 +1200111 }
112 }
113----
114
115SSL
116~~~
117
118To enable Nginx to perform the SSL processing, use 'proxy-https://'
119in httpd.listenUrl within Gerrit's configuration file, and enable
120the SSL engine in the Nginx server statement:
121
122----
123 server {
124 listen 443;
Piotr Sikora2e6a4ae2011-04-13 17:11:18 +0000125 server_name review.example.com;
Francois Marier624f4472011-04-13 15:58:14 +1200126
127 ssl on;
128 ssl_certificate conf/server.crt;
129 ssl_certificate_key conf/server.key;
130
131 ... same as above ...
132 }
133----
134
135See the Nginx 'http ssl module' documentation for more details on
136how to configure SSL within the server, like controlling how strong
137of an encryption algorithm is required.
138
Steffen Gebert832014f2013-06-03 21:42:47 +0200139Troubleshooting
140~~~~~~~~~~~~~~~
141
142If you are encountering 'Page Not Found' errors when opening the change
143screen, your Nginx proxy is very likely decoding the passed URL.
144Make sure to use a 'proxy_pass' URL without any path (esp. no trailing
145'/' after the 'host:port').
146
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800147GERRIT
148------
149Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700150
151SEARCHBOX
152---------