Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a rails server running on URL "http://example.com:1234" I want to provide the URL of this application to an user as "http://example.com/myapp" so that Apache (or Rack or whatever you suggest that works) can redirect request for "/myapp" to port 3333 of that domain.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

Take a look at setting up a Reverse Proxy under apache.

Apache, listening to port 80 on example.com, would reverse proxy to port 1234. Then requests for http://example.com/myapp would be internally proxied to http://example.com:1234/myapp (or however you setup your ProxyPass target).

If you don't have access to server config, you can use mod_rewrite's Proxy flag and setup some rules inside an .htaccess file. Something along the lines of:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^myapp(.*) http://example.com:1234/$1 [P,L]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...