2013-03-24 48 views
4

我無法從nexus獲取工件,我希望社區能幫助我。訪問和使用nexus web應用程序並不是問題(我已將基本URL設置爲https://www.fakesitename.com/nexus)。如何配置maven settings.xml以訪問apache代理後面的nexus

https://www.fakesitename.com/nexus所有呼叫重定向/轉發/代理(什麼是正確的術語?)到內部服務器在網絡上

<VirtualHost *:443> 
    ServerName www.fakesitename.com 
    ServerAdmin [email protected] 

    DocumentRoot /var/www 
    <Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
    </Directory> 

    ErrorLog ${APACHE_LOG_DIR}/error.log 
    LogLevel warn 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 

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

    ProxyRequests Off 
    ProxyPreserveHost On 

    ProxyPass /nexus http://192.168.0.178:8081/nexus 
    ProxyPassReverse /nexus http://192.168.0.178:8081/nexus 

    SSLEngine on 
    SSLCertificateFile /certs/mysite/ssl.crt 
    SSLCertificateKeyFile /certs/mysite/ssl.key 
</VirtualHost> 

settings.xml文件:

<?xml version="1.0" encoding="UTF-8"?> 
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
      http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
    <mirrors> 
    <mirror> 
     <id>public</id> 
     <mirrorOf>*</mirrorOf> 
     <url>https://www.fakesitename.com/nexus/content/groups/public</url> 
    </mirror> 
    </mirrors> 

<!-- What should be in here? 
    <proxies> 
    <proxy> 
     <id>myproxy</id> 
     <active>true</active> 
     <protocol>https</protocol> 
     <host>www.fakesitename.com</host> 
     <port>443</port> 
     <nonProxyHosts>127.0.0.1|192.168.0.178</nonProxyHosts> 
    </proxy> 
    </proxies> 
--> 
    <servers> 
    <server> 
     <id>releases</id> 
     <username>deployment</username> 
     <password>deployment123</password> 
    </server> 
    <server> 
     <id>snapshots</id> 
     <username>deployment</username> 
     <password>deployment123</password> 
    </server> 
    </servers> 
    <profiles> 
    <profile> 
     <id>nexus</id> 
     <repositories> 
     <repository> 
      <id>central</id> 
      <url>https://www.fakesitename.com/nexus/content/groups/public</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </repository> 
     </repositories> 
     <pluginRepositories> 
     <pluginRepository> 
      <id>central</id> 
      <url>https://www.fakesitename.com/nexus/content/groups/public</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </pluginRepository> 
     </pluginRepositories> 
    </profile> 
    </profiles> 
    <activeProfiles> 
    <activeProfile>nexus</activeProfile> 
    </activeProfiles> 
</settings> 

當我運行例如mvn clean一個項目的代理部分outcommented我得到...同行未驗證...

[INFO] Scanning for projects... 
Downloading: https://www.fakesitename.com/nexus/content/groups/public/com/fakesitename/poms/super/1.3/super-1.3.pom 
[ERROR] The build could not read 1 project -> [Help 1] 
[ERROR] 
[ERROR] The project com.fakesitename.library:application:1.3-SNAPSHOT (/tmp/application/pom.xml) has 1 error 
[ERROR]  Non-resolvable parent POM: Could not transfer artifact com.fakesitename.poms:super:pom:1.3 from/to public (https://www.fakesitename.com/nexus/content/groups/public): peer not authenticated and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException 
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException 

Ĵ

,並與部分不outcommented

[INFO] Scanning for projects... 
Downloading: https://www.fakesitename.com/nexus/content/groups/public/com/fakesitename/poms/super/1.3/super-1.3.pom 
mar 24, 2013 10:12:39 EM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryConnect 
INFO: I/O exception (org.apache.maven.wagon.providers.http.httpclient.NoHttpResponseException) caught when connecting to the target host: The target server failed to respond 
mar 24, 2013 10:12:39 EM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryConnect 
INFO: Retrying connect 
mar 24, 2013 10:12:39 EM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryConnect 
INFO: I/O exception (org.apache.maven.wagon.providers.http.httpclient.NoHttpResponseException) caught when connecting to the target host: The target server failed to respond 
mar 24, 2013 10:12:39 EM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryConnect 
INFO: Retrying connect 
mar 24, 2013 10:12:39 EM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryConnect 
INFO: I/O exception (org.apache.maven.wagon.providers.http.httpclient.NoHttpResponseException) caught when connecting to the target host: The target server failed to respond 
mar 24, 2013 10:12:39 EM org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultRequestDirector tryConnect 
INFO: Retrying connect 
[ERROR] The build could not read 1 project -> [Help 1] 
[ERROR] 
[ERROR] The project com.fakesitename.library:application:1.3-SNAPSHOT (/tmp/application/pom.xml) has 1 error 
[ERROR]  Non-resolvable parent POM: Could not transfer artifact com.fakesitename.poms:super:pom:1.3 from/to public (https://www.fakesitename.com/nexus/content/groups/public): The target server failed to respond and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException 
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException 

如果我更改設置文件直接使用 http://192.168.0.178:8081 ,它成功。

[INFO] Scanning for projects... 
Downloading: http://192.168.0.178:8081/nexus/content/groups/public/com/fakesitename/poms/super/1.3/super-1.3.pom 
Downloaded: http://192.168.0.178:8081/nexus/content/groups/public/com/fakesitename/poms/super/1.3/super-1.3.pom (33 KB at 157.3 KB/sec) 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Build Order: 
[INFO] 
... 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1.243s 
[INFO] Finished at: Sun Mar 24 22:22:01 CET 2013 
[INFO] Final Memory: 6M/17M 
[INFO] ------------------------------------------------------------------------ 

所以,我真的不知道該怎麼做。我希望能夠使用settings.xml文件中的「官方」https地址

+0

「peer not authenticated」通常表示服務器提供的SSL證書未由客戶端JRE知曉的權限(例如,自簽名)簽名。如果是這種情況,您需要將CA證書導入JRE的信任存儲(或者用您自己的方式覆蓋它)。 – nabcos 2013-03-25 08:25:16

+0

@nabcos你的假設是正確的。我不得不將StartSSL的CA證書添加到密鑰庫中。如果您將您的評論重新發布爲答案,我會接受它。 – 2013-03-25 10:58:26

回答

6

「peer not authenticated」通常表示服務器提供的SSL證書未由客戶端JRE知道的權限簽名(例如,自簽名)。

如果是這種情況,您需要將CA證書導入JRE的信任存儲區(或者用您自己的方式覆蓋它)。

+0

有關如何將證書導入JRE信任庫的說明,請參見http://www.sebsgarage.com/2012/09/adding-java-ssl-certificate-mac-osx/。 – Gili 2013-09-01 21:35:06

相關問題