rewrite server responses

Julien Vehent julien at linuxwall.info
Sat Oct 2 14:18:25 MSD 2010


On Sat, 2 Oct 2010 13:55:34 +0400, Igor Sysoev <igor at sysoev.ru> wrote:
> On Sat, Oct 02, 2010 at 11:49:50AM +0200, Julien Vehent wrote:
> 
>> Hello list,
>>
>> I have a nginx server that runs on 127.0.0.1:5004 (behind a load balancer) and I'm having difficulties with HTTP responses.
>> It seems that the application (in PHP5, Dotclear) sends a 302 when I try to connect to the admin panel, and this 302 redirects to <fqdn>:5004.
>>
>> I there any way to rewrite that response in nginx ?
> 
> port_in_redirect off;

I just put that in the location section, put it doesn't seem to take effect.


----------------------------------------------------------
GET /blog/admin/ HTTP/1.1
Host: example.net
[snip]


HTTP/1.1 302 Moved Temporarily
Server: nginx/0.7.67
Date: Sat, 02 Oct 2010 10:14:30 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: http://example.net:5004/blog/admin/auth.php
----------------------------------------------------------

The conf:

-------------
server {
        listen   127.0.0.1:5004;
        server_name  example.net;


        access_log  /var/log/nginx/example.net.access.log;
        root   /var/www;
        index  index.php index.html index.htm;
        location /ressources {
                autoindex on;
        }
        location /blog/admin {
                port_in_redirect off;
        }
        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_pass    unix:/var/run/spawn-fcgi-php5.socket;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }
}
-------------



Julien



More information about the nginx mailing list