重写规则隐藏的Rails服务器的URL端口? [英] Rewrite rule to hide port from URL of Rails server?

查看:202
本文介绍了重写规则隐藏的Rails服务器的URL端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个导轨服务器上的URLhttp://example.com:1234运行
我想提供这个应用程序的URL给用户作为http://example.com/myapp这样Apache(或机架或任何你认为工程)可以重定向/ MyApp的请求的端口3333域。

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.

推荐答案

看看建立一个反向代理在Apache 的。

阿帕奇,监听端口80上example.com,将反向代理端口1234。那么对于 http://example.com/myapp <​​请求/ A>将在内部被代理到 http://example.com:1234/myapp <​​/A>(或者无论你设置你的ProxyPass目标)

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).

如果您没有访问服务器的配置,你可以使用mod_rewrite的代理标志,并设置一些规则.htaccess文件中。沿着线的东西:

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]

这篇关于重写规则隐藏的Rails服务器的URL端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆