Welcome! Log In Create A New Profile

Advanced

External Redirect when expecting internal redirect

Thomas Glanzmann
March 10, 2013 08:32AM
Hello,
I'm running nginx 1.2.1-2.2 on Debian Wheezy (testing). I try to obtain
the following:

Depending on the subnet accessing either rewrite internally to a cgi
script or to a static Website. For the cgi script that works perfectly
fine, for the static web site nginx always does a HTTP 301 instead of an
internal rewrite. Here is a stripped down configuration demonstrating the
issue:

(mini) [/etc/nginx] cat nginx.conf
user www-data;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

geo $site {
127.0.0.0/8 eva;
default blank;
}

server {
listen 80;
server_name localhost;

root /var/www;

location /eva {
internal;
gzip off;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

fastcgi_param HTTPS $https;

fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /home/sithglan/work/scripts/web/eva.pl;
}

location /blank {
internal;
autoindex on;
autoindex_exact_size off;
}

location = / {
rewrite ^ /$site last;
}
}
}
(mini) [/etc/nginx] /etc/init.d/nginx restart
Restarting nginx: nginx.
(mini) [/etc/nginx] curl -I http://192.168.0.7/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.2.1
Date: Sun, 10 Mar 2013 12:28:44 GMT
Content-Type: text/html
Content-Length: 184
Location: http://192.168.0.7/blank/
Connection: keep-alive

(mini) [/etc/nginx] curl -I http://192.168.0.7/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.2.1
Date: Sun, 10 Mar 2013 12:28:47 GMT
Content-Type: text/html
Content-Length: 184
Location: http://192.168.0.7/blank/
Connection: keep-alive

I would like to acomplish that when 127.0.0.0/8 access the webserver the client
is internally redirected to eva.pl, which works, but if another ip address
access a website from static files is displayed, which works was well if I drop
the 'internal' keyword from location /blank but not using an internal redirect.

What do I have to change in order to make the internal rewrite for the files
work?

Cheers,
Thomas

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

External Redirect when expecting internal redirect

Thomas Glanzmann March 10, 2013 08:32AM

Re: External Redirect when expecting internal redirect

Francis Daly March 10, 2013 08:58AM

Re: External Redirect when expecting internal redirect

Thomas Glanzmann March 10, 2013 09:30AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 123
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready