# Nginx as reverse proxy to Hudson-Logout issue

**URL:** <https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216>\
**Category:** NGINX\
**Created:** [September 1, 2010, 7:46am UTC](https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216 "2010-09-01T07:46:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mogaroy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mogaroy](https://www.ruby-forum.com/u/mogaroy)\
**Post date:** [September 1, 2010, 7:46am UTC](https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216/1 "2010-09-01T07:46:37Z")

</div>

Hello list,

I have configured nginx as a reverse proxy to our hudson build server as  
follows:

[b]server {  
listen 80;  
server\_name koala.proxy.internal;

location /hudson/ {  
proxy\_pass [http://build.example.com/hudson/](http://build.example.com/hudson/);  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Host $host;  
proxy\_set\_header Host $http\_host;  
proxy\_redirect off;  
}[/b]

The backend hudson server is configured to authenticate users with  
Active Directory using  
the hudson active directory plugin.

Everything works fine, except that when I click the logout button,  
nothing happens, and  
I am still logged in, wheras the expected behaviour is, I should be  
logged out and taken  
to the login page.

The request and response headers in firebug show these:

Response:

HTTP/1.1 302 Moved Temporarily  
Server: nginx  
Date: Wed, 01 Sep 2010 02:40:57 GMT  
Connection: keep-alive  
Set-Cookie: ACEGI\_SECURITY\_HASHED\_REMEMBER\_ME\_COOKIE=“”; Path=/hudson  
Location: [http://koala.proxy.internal/hudson/](http://koala.proxy.internal/hudson/)  
Content-Length: 0  
Expires: Thu, 02 Sep 2010 02:40:57 GMT  
Cache-Control: max-age=86400

Request:

GET /hudson/logout HTTP/1.1  
Host: koala.proxy.internal  
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8)  
Gecko/20100722 Firefox/3.6.8  
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8  
Accept-Language: en-us,en;q=0.5  
Accept-Encoding: gzip,deflate  
Accept-Charset: ISO-8859-1,utf-8;q=0.7,\*;q=0.7  
Keep-Alive: 115  
Connection: keep-alive  
Referer: [http://koala.proxy.internal/hudson/people/](http://koala.proxy.internal/hudson/people/)  
Cookie: screenResolution=1280x720;  
JSESSIONID=8957FA425BC89DE784266DAACAD45135

Below are the headers from the hudson server, when I access it directly  
and click the logout  
button:

Response:

HTTP/1.1 200 OK  
Server: Apache-Coyote/1.1  
Expires: 0  
Content-Type: text/html;charset=UTF-8  
Transfer-Encoding: chunked  
Date: Wed, 01 Sep 2010 05:00:33 GMT

Request:

GET /hudson/login?from=%2Fhudson%2F HTTP/1.1  
Host: [build.example.com](http://build.example.com)  
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8)  
Gecko/20100722 Firefox/3.6.8  
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8  
Accept-Language: en-us,en;q=0.5  
Accept-Encoding: gzip,deflate  
Accept-Charset: ISO-8859-1,utf-8;q=0.7,\*;q=0.7  
Keep-Alive: 115  
Connection: keep-alive  
Referer: [http://build.example.com/hudson/](http://build.example.com/hudson/)  
Cookie: screenResolution=1280x720;  
JSESSIONID=105C0A7031B817E0321336310FC8D6E1

As I understand from the headers,when I click logout, the GET request  
should be for “/hudson/login?from=%2Fhudson%2F”  
and not for “/hudson/logout” as is happening through the reverse proxy.

I have tried many things to get it working but to no avail.Would really  
appreciate if someone  
could guide me here.

Thanks,  
Mogaroy

Posted at Nginx Forum:

> **[Nginx as reverse proxy to Hudson-Logout issue.](https://forum.nginx.org/read.php?2,125909,125909#msg-125909)**
>
> Hello list, I have configured nginx as a reverse proxy to our hudson build server as follows: \[b\]server { listen 80; server\_name koala.proxy.internal; location /hudson/ { proxy\_pass http:

---

<div class="post-metadata">

**Author:** ![mogaroy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mogaroy](https://www.ruby-forum.com/u/mogaroy)\
**Post date:** [September 7, 2010, 7:56am UTC](https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216/2 "2010-09-07T07:56:05Z")

</div>

For anyone who may be facing similar issues, I solved my problem by  
adding 'add\_header Pragma “no-cache”’ to my configuration.

> **[Common nginx configuration options](http://agiletesting.blogspot.com/2010/06/commong-nginx-configuration-options.html)**
>
> Google reveals a wealth of tutorials and sample nginx config files, but in any case here are some configuration tips that have been helpful ...

Thanks,  
Mogaroy

Posted at Nginx Forum:

> **[Re: Nginx as reverse proxy to Hudson-Logout issue.](https://forum.nginx.org/read.php?2,125909,127855#msg-127855)**
>
> Hello list, I have configured nginx as a reverse proxy to our hudson build server as follows: \[b\]server { listen 80; server\_name koala.proxy.internal; location /hudson/ { proxy\_pass http:

---

<div class="post-metadata">

**Author:** ![mogaroy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mogaroy](https://www.ruby-forum.com/u/mogaroy)\
**Post date:** [September 7, 2010, 8:00am UTC](https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216/3 "2010-09-07T08:00:46Z")

</div>

On Tue, Sep 07, 2010 at 01:54:54AM -0400, mogaroy wrote:

> For anyone who may be facing similar issues, I solved my problem by  
> adding 'add\_header Pragma “no-cache”’ to my configuration.
> 
> [Agile Testing: Common nginx configuration options](http://agiletesting.blogspot.com/2010/06/commong-nginx-configuration-options.html)

“Pragma: no-cache” is a client request header line.  
Although I saw an advise to add this line to a response many times,  
I’m not sure that browser or transient proxy server understands  
the header line in the response.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![mogaroy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mogaroy](https://www.ruby-forum.com/u/mogaroy)\
**Post date:** [September 7, 2010, 8:41am UTC](https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216/4 "2010-09-07T08:41:44Z")

</div>

Right Igor, checking further, found that the above solution works well  
with Firefox but not with IE.  
Any help please?

Thanks,  
Mogaroy

Posted at Nginx Forum:

> **[Re: Nginx as reverse proxy to Hudson-Logout issue.](https://forum.nginx.org/read.php?2,125909,127861#msg-127861)**
>
> Hello list, I have configured nginx as a reverse proxy to our hudson build server as follows: \[b\]server { listen 80; server\_name koala.proxy.internal; location /hudson/ { proxy\_pass http:

---

<div class="post-metadata">

**Author:** ![mogaroy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mogaroy](https://www.ruby-forum.com/u/mogaroy)\
**Post date:** [September 7, 2010, 9:56am UTC](https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216/5 "2010-09-07T09:56:08Z")

</div>

Fixed it for IE as well with this:

add\_header Cache-Control “no-cache”;

Thanks,  
Mogaroy

Posted at Nginx Forum:

> **[Re: Nginx as reverse proxy to Hudson-Logout issue.](https://forum.nginx.org/read.php?2,125909,127876#msg-127876)**
>
> Hello list, I have configured nginx as a reverse proxy to our hudson build server as follows: \[b\]server { listen 80; server\_name koala.proxy.internal; location /hudson/ { proxy\_pass http:

---

<div class="post-metadata">

**Author:** ![mogaroy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mogaroy](https://www.ruby-forum.com/u/mogaroy)\
**Post date:** [September 7, 2010, 10:22am UTC](https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216/6 "2010-09-07T10:22:30Z")

</div>

On Tue, Sep 07, 2010 at 03:54:55AM -0400, mogaroy wrote:

> Fixed it for IE as well with this:
> 
> add\_header Cache-Control “no-cache”;

Yes, this is right way.

However, this configuration is wrong:

location / {  
root /var/www;  
include cache-control.conf;  
index index.html index.htm;  
}

cache-control.conf:

# default cache 1 day

expires +1d;

if ($request\_uri ~\* “^/services/.\*$”) {  
expires +0d;  
add\_header Pragma “no-cache”;  
}

if ($request\_uri ~\* “^/(index.html)?$”) {  
expires +1h;  
}

It may work in some case and may not work in others.  
It should be rewritten as:

root /var/www;  
index index.html index.htm;

location = / {  
expires +1h;  
}

location = /index.html {  
expires +1h;  
}

location / {  
index index.html index.htm;  
expires +1d;  
}

location /services/ {  
index index.html index.htm;  
expires -1;  
}

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![mogaroy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mogaroy](https://www.ruby-forum.com/u/mogaroy)\
**Post date:** [September 7, 2010, 10:26am UTC](https://www.ruby-forum.com/t/nginx-as-reverse-proxy-to-hudson-logout-issue/194216/7 "2010-09-07T10:26:01Z")

</div>

On Tue, Sep 07, 2010 at 12:21:37PM +0400, Igor S. wrote:

> location / {  
> if ($request\_uri ~\* “^/services/.\*$”) {
> 
> location / {  
> index index.html index.htm;  
> expires +1d;  
> }
> 
> location /services/ {  
> index index.html index.htm;  
> expires -1;  
> }

Indecies in locations are not needed since they are inherited from  
the server level:

root /var/www;  
index index.html index.htm;

location = / {  
expires +1h;  
}

location = /index.html {  
expires +1h;  
}

location / {  
expires +1d;  
}

location /services/ {  
expires -1;  
}

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
