Rewrite rule to hide port from URL of Rails server?

前端 未结 2 1332
南旧
南旧 2020-12-19 21:23

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

相关标签:
2条回答
  • 2020-12-19 22:14

    Somethimes it loose it css style. You can use only:

    RewriteRule ^myapp(.*) http://example.com:1234 [L,R]
    
    0 讨论(0)
  • 2020-12-19 22:26

    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]
    
    0 讨论(0)
提交回复
热议问题