简体   繁体   中英

Apache forward request from port 80 to port 8000 based on url

I have a rails application running in apache on port 8000 and some PHP applications running on port 80. Now I'm accessing my rails application by giving port 8000 in the URL (like example.com/dashboard:8000 ).

I would like to access my rails application also without the port in the URL. So in apache I want to write a condition to check for url with /dashboard and forward those requests to port 8000 .

I cannot use sub-domains, so it has to be based on URL.

I've searched around and saw that we can use RewriteEngine for conditions on URL, but I'm not able to figure out exactly how to do it, and I'm new to apache configurations, so could someone please help me with it.

Thanks in advace

One simple solution would be to use ProxyPass to proxy the entire /dashboard subtree:

ProxyRequests Off
ProxyPass        /dashboard http://localhost:8000/dashboard
ProxyPassReverse /dashboard http://localhost:8000/dashboard

but be aware that your rails application needs to know that it probably shouldn't put the port number into the links, skyesheet refs, etc. it generates anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM