Error when setting up HTTPS protocol

Hello !

I’m struggling with the setup of the HTTPS protocol for the repository manager.
I’ve correctly installed and configured nginx to use the 443 port and to send requests to the website :

server {
    listen 443 ssl;
    server_name hereismydomain;
    ssl_certificate /etc/letsencrypt/live/hereismydomain/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/hereismydomain/privkey.pem;
    ssl_protocols       TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    location / {
        proxy_pass http://127.0.0.1:8081;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

The website works now with https, but the repositories URLs still are with “http”. This prevents me from getting any code from the nexus with Maven (since http protocol is not supported anymore by Maven from the 3.8.1 version, and I cannot downgrade Maven’s version).

I followed the tutorial to setup HTTPS : I first set application-ssl-port=443 in the nexus.properties file. I then uncommented the line nexus-args and added the argument ${jetty.etc}/jetty-https.xml. But when I restart with these parameters, I get this error :

java.lang.NoSuchMethodException: class org.eclipse.jetty.server.HttpConfiguration.setSecurePort(class java.lang.Object). Found setters for int
Jan 22 15:08:21 myname nexus[10470]:         at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:742)
Jan 22 15:08:21 myname nexus[10470]:         at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:509)
Jan 22 15:08:21 myname nexus[10470]:         at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.refObj(XmlConfiguration.java:1063)
Jan 22 15:08:21 myname nexus[10470]:         at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:530)
Jan 22 15:08:21 myname nexus[10470]:         at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:468)
Jan 22 15:08:21 myname nexus[10470]:         at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:380)
Jan 22 15:08:21 myname nexus[10470]:         at org.sonatype.nexus.bootstrap.jetty.JettyServer.doStart(JettyServer.java:168)
Jan 22 15:08:21 myname nexus[10470]:         at org.sonatype.nexus.bootstrap.jetty.JettyServer.lambda$0(JettyServer.java:117)
Jan 22 15:08:21 myname nexus[10470]:         at java.security.AccessController.doPrivileged(Native Method)
Jan 22 15:08:21 myname nexus[10470]:         at org.sonatype.nexus.bootstrap.jetty.JettyServer.start(JettyServer.java:115)
Jan 22 15:08:21 myname nexus[10470]:         at org.sonatype.nexus.bootstrap.Launcher.start(Launcher.java:131)
Jan 22 15:08:21 myname nexus[10470]:         at org.sonatype.nexus.bootstrap.Launcher.startAsync(Launcher.java:127)
Jan 22 15:08:21 myname nexus[10470]:         at org.sonatype.nexus.bootstrap.osgi.LauncherActivator.start(LauncherActivator.java:67)
Jan 22 15:08:21 myname nexus[10470]:         at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:698)
Jan 22 15:08:21 myname nexus[10470]:         at org.apache.felix.framework.Felix.activateBundle(Felix.java:2402)
Jan 22 15:08:21 myname nexus[10470]:         at org.apache.felix.framework.Felix.startBundle(Felix.java:2308)
Jan 22 15:08:21 myname nexus[10470]:         at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1539)
Jan 22 15:08:21 myname nexus[10470]:         at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
Jan 22 15:08:21 myname nexus[10470]:         at java.lang.Thread.run(Thread.java:750)
Jan 22 15:08:21 myname nexus[10470]:         Suppressed: java.lang.NoSuchMethodException: org.eclipse.jetty.server.HttpConfiguration.setSecurePort(java.lang.Object)
Jan 22 15:08:21 myname nexus[10470]:                 at java.lang.Class.getMethod(Class.java:1786)
Jan 22 15:08:21 myname nexus[10470]:                 at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:601)
Jan 22 15:08:21 myname nexus[10470]:                 ... 18 common frames omitted
Jan 22 15:08:21 myname nexus[10470]:         Suppressed: java.lang.NoSuchFieldException: TYPE
Jan 22 15:08:21 myname nexus[10470]:                 at java.lang.Class.getField(Class.java:1703)
Jan 22 15:08:21 myname nexus[10470]:                 at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:614)
Jan 22 15:08:21 myname nexus[10470]:                 ... 18 common frames omitted
Jan 22 15:08:21 myname nexus[10470]:         Suppressed: java.lang.NoSuchFieldException: securePort
Jan 22 15:08:21 myname nexus[10470]:                 at java.lang.Class.getField(Class.java:1703)
Jan 22 15:08:21 myname nexus[10470]:                 at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:629)
Jan 22 15:08:21 myname nexus[10470]:                 ... 18 common frames omitted
Jan 22 15:08:21 myname nexus[10470]:         Suppressed: java.lang.IllegalArgumentException: null
Jan 22 15:08:21 myname nexus[10470]:                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Jan 22 15:08:21 myname nexus[10470]:                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Jan 22 15:08:21 myname nexus[10470]:                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Jan 22 15:08:21 myname nexus[10470]:                 at java.lang.reflect.Method.invoke(Method.java:498)
Jan 22 15:08:21 myname nexus[10470]:                 at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.invokeMethod(XmlConfiguration.java:765)
Jan 22 15:08:21 myname nexus[10470]:                 at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:679)
Jan 22 15:08:21 myname nexus[10470]:                 ... 18 common frames omitted
Jan 22 15:08:21 myname nexus[10470]:         Suppressed: java.lang.NoSuchMethodException: java.lang.Integer.<init>(java.lang.Object)
Jan 22 15:08:21 myname nexus[10470]:                 at java.lang.Class.getConstructor0(Class.java:3082)
Jan 22 15:08:21 myname nexus[10470]:                 at java.lang.Class.getConstructor(Class.java:1825)
Jan 22 15:08:21 myname nexus[10470]:                 at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:725)
Jan 22 15:08:21 myname nexus[10470]:                 ... 18 common frames omitted

My nexus.properties file is :

nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-requestlog.xml
application-ssl-port=443

My nexus-default.properties file :

## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
 nexus-pro-feature

nexus.hazelcast.discovery.isEnabled=true

I’ve got the problem with two versions : the latest one (3.45) and the 3.41 version.

Does anybody know how to fix this ?
Regards,

In the nexus.properties you want to remove jetty-http.xml and keep jetty-https.xml.
and also add application-ssl-port=443 in nexus.properties
check if the nexus service is running: service network status cli …

-abdel

I’m not sure what you mean by your repository URLs are http.

Configuring jetty for https probably isn’t necessary if you’re configuring nginx as a reverse proxy.

(I reinstalled the nexus in order to get rid of the error that was showing up on nexus boot, in the aim for the panel to start.)

Even though the panel works great and the website shows as “https”, repositories urls show up as “http” and thus Maven can’t reach the Nexus when I setup the proxy as HTTPS in the settings.xml file (if I setup the proxy as http, I can deploy but not get anything since Maven does not support http proxies since the 3.8.1 version) hence I can’t download anything from it.

image

That’s my settings.xml file with the proxy in https :

<proxy>
		  <id>myproxy</id>
		  <active>true</active>
		  <protocol>https</protocol>
		  <username>admin</username>
		  <password>mypassword</password>
		  <host>hereismyip</host> 
		  <port>8081</port>         
</proxy>  

NB : I also tried to set the port “443” (as it is my https port), same error occurs.

I get this error when trying to deploy/get something with these settings with Maven : Connection timed out: connect.
The website works perfectly fine. The link I provided for the deploy is valid (this is a https link).

Thanks for your kind reply. Unfortunately, the clues that you’ve given me didn’t work.

Nexus will show the URLs based on the URL you used to access the UI.

When I visit my website the URL shows with “https”. However, the repositories URLs still remain in http. But that’s not my point : I literally can’t get anything from the nexus with Maven when the protocol is set as https (it gives me an error, I pasted it in my last message). I just can’t figure how to make this work.

Usually the symptoms you are describing occur when a reverse proxy/load balancer is running in front of Nexus Repo. If that isn’t setting the X-Forwarded-Proto header correctly outbound URL’s such as repository URL’s will show as http, rather than https. If you do have something running in front of Nexus Repo check its configuration. See here for examples:

https://help.sonatype.com/repomanager3/planning-your-implementation/run-behind-a-reverse-proxy#RunBehindaReverseProxy-Example:ReverseProxySSLTerminationatBasePath

Thanks for your precious help, it solved my problem.