Welcome! Log In Create A New Profile

Advanced

ssh-tunnel into website nginx strips out port number in response

May 25, 2012 03:32AM
Same post is made here:
http://serverfault.com/questions/392530/nginx-when-tunnel-the-url-redirects-without-port-number

But I will make a shorter version (as much as possible)

I want to be able to ssh-tunnel into my Django website, so I can work
remotely. I've tested a simple Django project on my personal computer, with
very simple nginx configuration (starter, default). I tunnel and
redirection returns with port number as part of the url. So I am sure this
is not a Django problem. It's mainly my nginx configuration.

Relevant code:

server {
> listen 80;
> server_name localhost 127.0.0.1;
> server_name_in_redirect off;
>
> # location other services go here
>
> location ~ /forum/(.*)$ {
> #rewrite ^(.*):(.*)/forum(.*)$ /$2 last;
> #rewrite ^(.*)$ http://localhost:8000/$1;
> #rewrite ^/forum(.*)$ $1 break;
>
> # the forum service runs as local, listens to 8000 port...
> proxy_pass http://localhost:8000;
> proxy_redirect default;
>
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> }
>
>
Then I ssh-tunnel, open the browser, http://localhost:1111, and when I
login, or do anything that requires redirection, I get
http://localhost/forum/front-page http://yahoo.com/ instead of
http://localhost:1111/froum/front-page http://yahoo.com/

These links are wrong, nginx will complain (from the server side) they do
not exist.

I've tried stuff like

proxy_set_header $host:$server_port; # or
proxy_set_header $proxy_host:$proxy_port; # or
proxy_set_header $host:$proxy_port; # or
rewrite ^(.*):(.*)/forum(.*)$ /$2 last;
#rewrite ^/forum(.*)$ $1 break;
proxy_redirect http://localhost/ http://$host:$proxy_port;

The 2nd proxy_set_header shows a little progress. After pressing submit, I
get a blank page, with the original url (http://localhost:1111/post and
then I see the same url again).

Any idea how to resolve my problem? Thanks.

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

ssh-tunnel into website nginx strips out port number in response

jwxie May 25, 2012 03:32AM

Re: ssh-tunnel into website nginx strips out port number in response

jwxie May 26, 2012 03:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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