Welcome! Log In Create A New Profile

Advanced

nginx usptream 302 redirect

Anatoli Marinov
October 04, 2013 10:36AM
Hello,
Is there an easy way to configure nginx upstream to follow 302 instead of
send them to the browser?

I tried with this config:

http {
proxy_intercept_errors on;

proxy_cache_path /home/toli/nginx/run/cache keys_zone=zone_c1:256m
inactive=5d max_size=30g;

upstream up_servers {
server 127.0.1.1:8081;
}

server {
listen 127.0.0.1:8080;

location / {
proxy_cache zone_c1;
proxy_pass http://127.0.1.1:8081;
proxy_temp_path tmp ;

error_page 301 302 307 @redir;
}

location @redir {
proxy_cache zone_c1;
proxy_pass $upstream_http_location;
proxy_temp_path tmp ;
}
}
}

Unfortunately it do not work. I receive "500: Internal Server Error."
and in the logs I have [invalid URL prefix in ""]

From dev mail list Maxim advised me to backup $upstream_http_location in
other variable and I did it but the result was the same - 500 internal
server error. The config after the fix is:


http {
proxy_intercept_errors on;

proxy_cache_path /home/toli/nginx/run/cache keys_zone=zone_c1:256m
inactive=5d max_size=30g;

upstream up_servers {
server 127.0.1.1:8081;
}

server {
listen 127.0.0.1:8080;

location / {
proxy_cache zone_c1;
proxy_pass http://127.0.1.1:8081;
proxy_temp_path tmp ;
set $foo $upstream_http_location;
error_page 301 302 307 @redir;
}

location @redir {
proxy_cache zone_c1;
proxy_pass $foo;
proxy_temp_path tmp ;
}
}
}

Do you have any idea how this could be achieved.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx usptream 302 redirect

Anatoli Marinov October 04, 2013 10:36AM

Re: nginx usptream 302 redirect

Maxim Dounin October 04, 2013 11:14AM

Re: nginx usptream 302 redirect

Mingcai SHEN March 18, 2015 09:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 241
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