2016-07-19 4 views
0

OS - Ubuntu 14.04.3 LTCWie gerrit auf tomcat7 mit http auth auf Apache einzurichten

git, tomcat7, mysql, apache2 installiert wurden.

konfiguriert I tomcat7 SSL zu unterstützen: server.xml

<Connector port="4432" protocol="HTTP/1.1" SSLEnabled="true" 
       maxThreads="150" scheme="https" secure="true" 
       clientAuth="false" sslProtocol="TLS" 
       keystoreFile="some_path" 
       keystorePass="some_pass" /> 

Und verwendete MySQL-Datenbank: context.xml

<Resource name="jdbc/ReviewDb" 
      auth="Container" 
      type="javax.sql.DataSource" 
      driverClassName="com.mysql.jdbc.Driver" 
      url="jdbc:mysql://localhost:3306/gerrit_reviewdb" 
      username="gerrit" 
      password="gerrit" 
      maxActive="20" 
      maxIdle="10" 
      maxWait="-1"/> 

I eingesetzt gerrit auf tomcat7 mit Typ Auth development_become_any_account.

Weiter habe ich Datei gerrit_auth.conf in Ordner/etc/apache2/sites-available

Listen 82 
<VirtualHost *:82> 
     ServerName localhost 
     ProxyRequests Off 
     ProxyVia Off 
     ProxyPreserveHost On 
     AllowEncodedSlashes On 
     <Proxy *> 
       Order deny,allow 
       Allow from all 
     </Proxy> 

     <Location /gerrit/login/> 
       AuthType Basic 
       AuthName "Gerrit Code Review2" 
       AuthBasicProvider file 
       AuthUserFile /var/opt/gerrit/users/passwords 
       Require valid-user 
     </Location> 

     ProxyPass /gerrit/ https://localhost:4432/gerrit/ nocanon 
     ErrorLog /var/opt/gerrit/apache_errorlog.log 
     CustomLog /var/opt/gerrit/apache_customlog.log combined 
</VirtualHost> 

Und chaged Auth Typ http in gerrit.config

[gerrit] 
     basePath = /var/opt/gerrit/repositories 
     canonicalWebUrl = https://my_gerrit_site:4432/gerrit 
[database] 
     type = mysql 
     database = gerrit_reviewdb 
     hostname = localhost 
     username = gerrit 
[index] 
     type = LUCENE 
[auth] 
     type = http 
[receive] 
     enableSignedPush = false 
[sendemail] 
     smtpServer = localhost 
[container] 
     user = tomcat7 
     javaHome = /usr/lib/jvm/jdk1.7.0_79/jre 
[sshd] 
     listenAddress = *:29418 
[httpd] 
     listenUrl = proxy-http://localhost:82/ 
[cache] 
     directory = cache 

und neu gestartet Dienste Apache2 und Tomcat7. Jetzt , wenn ich gehe zu https: // my_gerrit_site: 4432/Ich sehe tomcat7

Es funktioniert!

, wenn ich gehe zu https: // my_gerrit_site: 4432/gerrit Ich sehe

Konfigurationsfehler

Überprüfen Sie die Authentifizierungseinstellungen des HTTP-Servers.

Der HTTP-Server hat den Benutzernamen im Autorisierungs-Header nicht angegeben, als er die Anfrage an Gerrit Code Review weitergeleitet hat.

Wenn der HTTP-Server Apache httpd, überprüfen Sie die Proxy-Konfiguration enthält eine Genehmigungsrichtlinie mit der richtigen Position, um sicherzustellen, es mit '/' endet:

Server my_gerrit_site

ProxyRequests Off 
ProxyVia Off 
ProxyPreserveHost On 

<Proxy *> 
     Order deny,allow 
     Allow from all 
</Proxy> 

<Location /gerrit/login/> 
    AuthType Basic 
    AuthName "Gerrit Code Review" 
    Require valid-user 
    ... 
</Location> 

AllowEncodedSlashes On 
ProxyPass /gerrit/ http://.../gerrit/ nodecode </VirtualHost> 

wenn ich gehe http: // my_gerrit_site: 82/ich sehe

Index of/

Apache/2.4.7 (Ubuntu) Server auf my_gerrit_site Hafen 82

, wenn ich gehe zu http: // my_gerrit_site: 82/gerrit/login/I Fenster mit Authentifizierung zu sehen, und wenn ich mich anmelde sehe ich

Internal Server Error 
The server encountered an internal error or misconfiguration and was unable to complete your request. 

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error. 

More information about this error may be available in the server error log. 

Apache/2.4.7 (Ubuntu) Server at my_gerrit_site Port 82 

apache_errorlog.log

[Tue Jul 19 20:18:39.067497 2016] [proxy:warn] [pid 6382:tid 140713740175104] [client x.x.x.x:27949] AH01144: No protocol handler was valid for the URL /gerrit/login/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule. 

catalina.out

[2016-07-19 20:18:18,855] [http-bio-4432-exec-6] ERROR com.google.gerrit.httpd.auth.container.HttpLoginServlet : Unable to authenticate user by Authorization request header. Check container or server configuration. 

Was ich falsch gemacht? Welche Einstellungen muss ich ändern?

Dank

+0

Warum Sie Tomcat verwenden? Ist es erforderlich? Es ist besser, Gerrit selbst arbeiten zu lassen. – uncletall

+0

Ja, ich benutze Tomcat, weil es Voraussetzung ist –

Antwort

2
Problem was with apache2 and virtual host configuration. 

Als ich versucht habe, Proxy, Proxy_http, Proxy_ajp, ssl (a2enmod) zu aktivieren, hatte ich einen Fehler mit einem von zwei virtuellen Hosts (Dateien ihrer Konfigurationen wurden erstellt und aktiviert, wenn ich versuche, http Auth für meine gerrit). Also, wenn ich (a2dissite) virtuellen Host mit schlechter Konfiguration deaktiviert habe, hatte ich keine Fehler.

Arbeits apache2 Konfiguration für HTTP Auth:

LoadModule ssl_module modules/mod_ssl.so 
Listen 4433 

<VirtualHost *:4433> 
     ServerName localhost 

     ProxyRequests Off 
     ProxyVia Off 
     ProxyPreserveHost On 
     SSLProxyEngine on 
     SSLProxyVerify none 
     SSLProxyCheckPeerCN off 
     SSLProxyCheckPeerName off 
     SSLProxyCheckPeerExpire off 

     # SSL Engine Switch: 
     # Enable/Disable SSL for this virtual host. 
     SSLEngine on 

     # A self-signed (snakeoil) certificate can be created by installing 
     # the ssl-cert package. See 
     # /usr/share/doc/apache2/README.Debian.gz for more info. 
     # If both key and certificate are stored in the same file, only the 
     # SSLCertificateFile directive is needed. 
     SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem 
     SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key 

     #AllowEncodedSlashes On 

     <Proxy *> 
       Order deny,allow 
       Allow from all 
     </Proxy> 

     <Location /gerrit/login/> 
       AuthType Basic 
       AuthName "Gerrit Code Review" 
       AuthBasicProvider file 
       AuthUserFile /var/opt/gerrit/users/passwords 
       Require valid-user 
     </Location> 
     ProxyPass /gerrit/ https://localhost:4432/gerrit/ 

     # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
     # error, crit, alert, emerg. 
     # It is also possible to configure the loglevel for particular 
     # modules, e.g. 
     #LogLevel info ssl:warn 

     ErrorLog /var/opt/gerrit/apache_errorlog.log 
     CustomLog /var/opt/gerrit/apache_customlog.log combined 
</VirtualHost> 
0

Sie müssen die canonocalWebUrl an die externe URL

canonicalWebUrl = https://my_gerrit_site:82/gerrit 
+0

leider, es funktioniert nicht. Alle sind dieselben Fehler und Internet Explorer kann die Webseite nicht anzeigen (https: // my_gerrit_site: 82 und/gerrit). Wie ich Apache verstehe benutze http (nicht https) –