Welcome! Log In Create A New Profile

Advanced

Re: nginx redirect problem

March 24, 2011 04:24AM
On Thu, Mar 24, 2011 at 09:26:42AM +0800, lhmwzy wrote:
> here is the conf:
>
> server {
> listen 10.68.150.4:82;
> server_name h.test.com;
> root /usr/www;
>
> location / {
> index index.html index.htm index.php;
> }
>
> error_page 500 502 503 504 /50x.html;
> location = /50x.html {
> root /usr/local/www/nginx-dist;
> }
>
> location ~ \.php$ {
> fastcgi_pass unix:/tmp/php-fastcgi.sock;
> include fastcgi_params;
> fastcgi_index index.php;
> }
> }
>
> I have a router in the front,and have set a port map
>
> 67.xx.xx.xx:8081-->10.68.150.4:82
>
> But there is a problem
> When I visit http://h.test.com:8081/house,the redirected to
> http://h.test.com/house/.
> How can make it redirct http://h.test.com:8081/house/ when visit
> http://h.test.com:8081/house?

You can try the following:

server {
listen 10.68.150.4:82;
server_name h.test.com:8081 h.test.com;

location / {
server_name_in_redirect on;
port_in_redirect off;
...

"server_name_in_redirect on" forces to use a fictitious first server_name
"h.test.com:8081" in a redirect. "port_in_redirect off" disables
a real 82 port in redirect. If you omit port_in_redirect you will get

http://h.test.com:8081:82/house/


--
Igor Sysoev
http://sysoev.ru/en/

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

nginx redirect problem

lhmwzy March 23, 2011 09:28PM

Re: nginx redirect problem

Igor Sysoev March 24, 2011 04:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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