# Redirecting without canonicalizing the port

**URL:** <https://www.ruby-forum.com/t/redirecting-without-canonicalizing-the-port/200597>\
**Category:** NGINX\
**Created:** [December 17, 2010, 12:59am UTC](https://www.ruby-forum.com/t/redirecting-without-canonicalizing-the-port/200597 "2010-12-17T00:59:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 17, 2010, 12:59am UTC](https://www.ruby-forum.com/t/redirecting-without-canonicalizing-the-port/200597/1 "2010-12-17T00:59:34Z")

</div>

Can I redirect to a URL that uses the port number in the request, as  
opposed to the port specified in `listen`? (so as to work with  
proxies/tunnels)

E.g., if I have `listen 444` and have a tunnel so that my client is  
surfing [http://localhost:4444](http://localhost:4444), I don’t want my redirects to send the  
client to [http://localhost:444](http://localhost:444), which is currently the case - I want  
the port number to be reflected back, not “canonicalized.”

Thanks in advance for any hints.

---

<div class="post-metadata">

**Author:** ![Yang\_Z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e274bd/32.png) [@Yang\_Z](https://www.ruby-forum.com/u/Yang_Z)\
**Post date:** [December 17, 2010, 1:07am UTC](https://www.ruby-forum.com/t/redirecting-without-canonicalizing-the-port/200597/2 "2010-12-17T01:07:41Z")

</div>

This seems to happen for all redirects (e.g. rewrites), but if it  
makes any difference, the particular redirect I’m interested in is  
from

location /foo { alias /…/foo; }

Requests to /foo get redirected to /foo/ (but with the wrong port  
number, as described below).
