blob: 7161c4a223387e9198b49fa6a0fe435f39142dff [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
31To run Gerrit behind an Apache server using 'mod_proxy', enable the
32necessary Apache2 modules:
33
34----
35 a2enmod proxy_http
36 a2enmod ssl ; # optional, needed for HTTPS / SSL
37----
38
Shawn O. Pearcee240de12010-02-13 12:07:53 -080039Configure 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
48 ProxyRequests Off
49 ProxyVia Off
50 ProxyPreserveHost On
51
52 <Proxy *>
53 Order deny,allow
54 Allow from all
55 </Proxy>
56
57 ProxyPass /r/ http://127.0.0.1:8081/r/
58 </VirtualHost>
59----
60
61SSL
62~~~
63
64To enable Apache to perform the SSL processing, use 'proxy-https://'
65in httpd.listenUrl within Gerrit's configuration file, and enable
66the SSL engine in the Apache VirtualHost block:
67
68----
69 <VirtualHost *:443>
70 SSLEngine on
71 SSLCertificateFile conf/server.crt
72 SSLCertificateKeyFile conf/server.key
73
74 ... same as above ...
75 </VirtualHost>
76----
77
78See the Apache 'mod_ssl' documentation for more details on how to
79configure SSL within the server, like controlling how strong of an
80encryption algorithm is required.
81
Francois Marier624f4472011-04-13 15:58:14 +120082
83Nginx Configuration
84-------------------
85
86To run Gerrit behind an Nginx server, use a server statement such
87as this one:
88
89----
90 server {
91 listen 80;
Piotr Sikora2e6a4ae2011-04-13 17:11:18 +000092 server_name review.example.com;
Francois Marier624f4472011-04-13 15:58:14 +120093
94 location /r/ {
Piotr Sikora2e6a4ae2011-04-13 17:11:18 +000095 proxy_pass http://127.0.0.1:8081;
96 proxy_set_header X-Forwarded-For $remote_addr;
97 proxy_set_header Host $host;
Francois Marier624f4472011-04-13 15:58:14 +120098 }
99 }
100----
101
102SSL
103~~~
104
105To enable Nginx to perform the SSL processing, use 'proxy-https://'
106in httpd.listenUrl within Gerrit's configuration file, and enable
107the SSL engine in the Nginx server statement:
108
109----
110 server {
111 listen 443;
Piotr Sikora2e6a4ae2011-04-13 17:11:18 +0000112 server_name review.example.com;
Francois Marier624f4472011-04-13 15:58:14 +1200113
114 ssl on;
115 ssl_certificate conf/server.crt;
116 ssl_certificate_key conf/server.key;
117
118 ... same as above ...
119 }
120----
121
122See the Nginx 'http ssl module' documentation for more details on
123how to configure SSL within the server, like controlling how strong
124of an encryption algorithm is required.
125
Shawn O. Pearce9ad8ba52009-12-11 19:06:21 -0800126GERRIT
127------
128Part of link:index.html[Gerrit Code Review]