Using CLI with Nginx behind Jenkins

519 views
Skip to first unread message

mpapo - Michaël Pailloncy

unread,
Feb 7, 2014, 7:48:23 AM2/7/14
to jenkins...@googlegroups.com
Hi all,

We've an issue using CLI with Jenkins behind Nginx .

Jenkins URL : http://host:8081/ic
Nginx reverse proxy URL : http://nicely-named-host/ic


With a browser, Jenkins responds correctly to all http requests. There isn't any reverse proxy configuration alert in http://nicely-named-host/ic/manage.

Command OK : java -jar jenkins-cli.jar -s http://host:8081/ic help
Command KO : java -jar jenkins-cli.jar -s http://nicely-named-host/ic help

Error: 

Exception in thread "main" java.net.ConnectException: Connection refused: connect

        at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)

        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)

        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)

        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)

        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)

        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)

        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

        at java.net.Socket.connect(Socket.java:579)

        at hudson.cli.CLI.connectViaCliPort(CLI.java:211)

        at hudson.cli.CLI.<init>(CLI.java:134)

        at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)

        at hudson.cli.CLI._main(CLI.java:469)

        at hudson.cli.CLI.main(CLI.java:384)

        Suppressed: java.io.EOFException: unexpected stream termination

                at hudson.remoting.ClassicCommandTransport.create(ClassicCommandTransport.java:135)

                at hudson.remoting.Channel.<init>(Channel.java:406)

                at hudson.remoting.Channel.<init>(Channel.java:402)

                at hudson.remoting.Channel.<init>(Channel.java:363)

                at hudson.remoting.Channel.<init>(Channel.java:359)

                at hudson.remoting.Channel.<init>(Channel.java:347)

                at hudson.cli.CLI.connectViaHttp(CLI.java:165)

                at hudson.cli.CLI.<init>(CLI.java:138)

                ... 3 more


Does somebody have an idea why I can't connect to Jenkins using CLI if it's behind a reverse proxy ? 

Thanks in advance.

Michaël Pailloncy

Craig Rodrigues

unread,
Feb 7, 2014, 5:55:16 PM2/7/14
to jenkins...@googlegroups.com
On Fri, Feb 7, 2014 at 4:48 AM, mpapo - Michaël Pailloncy <mpap...@gmail.com> wrote:
Hi all,

We've an issue using CLI with Jenkins behind Nginx .

Jenkins URL : http://host:8081/ic
Nginx reverse proxy URL : http://nicely-named-host/ic



I didn't use that config for NGINX.  Here is my nginx.conf which is much simpler:


worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;


    server {
        listen       80;

        # Redirect all port 80 requests to Jenkins on
        # port 8180
        return 301 http://$host:8180/jenkins/$request_uri;
    }

}



 
If you don't mind having something simpler which just does HTTP 301 redirect
instead of the reverse proxy config, you can see if that works better for you.

--
Craig

mpapo - Michaël Pailloncy

unread,
Feb 10, 2014, 5:48:02 AM2/10/14
to jenkins...@googlegroups.com, rod...@freebsd.org
Hi,

Thanks to share your config.
However, we would like to keep reverse proxy configuration for maintenance convenience.

Another idea why CLI doesn't work with Jenkins behind a reverse proxy ?

mpapo - Michaël Pailloncy

unread,
Feb 10, 2014, 5:50:54 AM2/10/14
to jenkins...@googlegroups.com, rod...@freebsd.org
The bug is already tracked :  https://issues.jenkins-ci.org/browse/JENKINS-16345 
Sorry for the noise.

Michaël
Reply all
Reply to author
Forward
0 new messages