sne11ius
sne11ius

Reputation: 726

Jenkins behind nginx without subdirectory

I have Jenkins running inside my Glassfish installation, so Jenkins can be reached @

http://localhost:8090/jenkins/

I managed to setup nginx so Jenkins can be reached from the outside @

http://build.example.com/jenkins/

This setup works well so far, but I am not really happy with it. What I would really want to achieve is to hit

http://build.example.com

in the browser to reach Jenkins.

Here is my current nginx config:

server {
    listen   80;

    server_name build.example.com;

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

I hope this is possible via some url rewrite, but I'm totally clueless how to do it...

Upvotes: 1

Views: 3706

Answers (3)

Eric Platon
Eric Platon

Reputation: 10152

It seems to me the problem is the Glassfish configuration.

How about setting in application.xml the following value:

<context-root/>

Instead of the default, which is the name of the WAR file, without the .war extension.

There seems to be similar questions on SO.

Upvotes: 1

Gaurav Joseph
Gaurav Joseph

Reputation: 946

From http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

location / {
    rewrite    /jenkins/(.*) /$1 break;
    proxy_pass http://localhost:8090/jenkins/;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
}

Upvotes: 0

VBart
VBart

Reputation: 15110

Then change:

proxy_pass http://localhost:8090;

to

proxy_pass http://localhost:8090/jenkins/;

Reference: http://nginx.org/r/proxy_pass

Upvotes: 1

Related Questions