# Original port from apache needed in rails ? RequestHeader?

**URL:** <https://www.ruby-forum.com/t/original-port-from-apache-needed-in-rails-requestheader/110362>\
**Category:** Rails\
**Created:** [July 25, 2007, 7:23pm UTC](https://www.ruby-forum.com/t/original-port-from-apache-needed-in-rails-requestheader/110362 "2007-07-25T19:23:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uncle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/e5b9ba/32.png) [@uncle](https://www.ruby-forum.com/u/uncle)\
**Post date:** [July 25, 2007, 7:23pm UTC](https://www.ruby-forum.com/t/original-port-from-apache-needed-in-rails-requestheader/110362/1 "2007-07-25T19:23:09Z")

</div>

I have a web app that listens on 443 and 444 via apache, I need to  
know in my rails app which port the request came from. I think  
something with the RequestHeader directive is required, but not sure  
how to do it…

any ideas ???

---

<div class="post-metadata">

**Author:** ![uncle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/e5b9ba/32.png) [@uncle](https://www.ruby-forum.com/u/uncle)\
**Post date:** [July 25, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/original-port-from-apache-needed-in-rails-requestheader/110362/2 "2007-07-25T21:30:20Z")

</div>

found it…you can add this to your apache config…

#===== server port  
RewriteCond %{SERVER\_PORT} (._)  
RewriteRule ._ - [E=X\_SERVER\_PORT:%1]  
RequestHeader add HTTP\_X\_SERVER\_PORT %{X\_SERVER\_PORT}e

must have apache 2.2 or better  
mongrel (or whatever) will see a new header HTTP\_X\_SERVER\_PORT
