Apache의 하위 디렉토리에서 Ruby on Rails 앱 구성
-
19-08-2019 - |
문제
Windows에 Apache2.2가 있습니다. 나는 Subversion (/svn)과 Redmine (/redmine)을 모두 제공하려고 노력하고 있습니다. 이 구성으로 SVN이 잘 실행됩니다.
<Location /svn>
DAV svn
SVNParentPath C:/svn_repository
...
</Location>
이것은 크게 작동합니다 http : // mybox/svn 괜찮아.
이제 Rails 앱 (Redmine) 용 다른 디렉토리를 추가하고 싶습니다.
나는 조언을 따랐다 이 질문 Mongrel Server를 설정하고 Apache 프록시 클라이언트를 이용할 수 있습니다. 루트로 만들면 잘 작동하지만 하위 디렉토리로 만드는 데 어려움이 있습니다.
<Location /redmine>
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
제안이 있습니까?
해결책
내가 바꾸어야 할 사항은 다음과 같습니다.
후행 슬래시를 제거했습니다.
<Location /redmine>
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000/
</Location>
그리고 내 레일 앱에서 :
# added to end of file C:\redmine\config\environment.rb
ActionController::AbstractRequest.relative_url_root = "/redmine"
이제 작동합니다!
나는이 접근법에 완전히 만족하지 않았다. 나는 몇 가지 리디렉션 문제를 해결했다. 이것은 지금까지 잘 작동하는 또 다른 시도입니다.
이 두 번째 접근법이 더 좋아 보입니다.
업데이트:
주석에 언급 된 바와 같이, Rails 2.3.2+에서 실행되는 최신 앱의 경우 대신 사용하십시오.
config.action_controller.relative_url_root = '/redmine'
나는 그것을 새로 넣었다 additional_environment.rb
파일.
다른 팁
리버스 프록시를 사용하여 Mongrel + Apache를 사용하려는 경우 여기서 시스템에서 동일한 문제를 해결하는 방법 (Win2k3, Apache 2.2, Redmine 트렁크)이 어떻게 해결되었는지입니다. 비밀은 Mongrel 서비스를 사용하여 설치하는 것입니다 --prefix /redmine
그것을 제공하라고 말합니다 http://localhost:port/redmine
Apache에서 httpd.conf (또는 적절한 포함 파일)에서 :
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<IfModule mod_proxy.c>
ProxyRequests Off
#No need to forward on static content - let apache do it faster
ProxyPass /redmine/images !
ProxyPass /redmine/stylesheets !
ProxyPass /redmine/javascript !
# Remove the following entry on public sites as this is insecure
ProxyPass /redmine/plugin_assets !
ProxyPass /redmine/help !
ProxyPass /redmine http://localhost:4000/redmine
ProxyPassReverse /redmine http://localhost:4000/redmine
ProxyPreserveHost On
#continue with other static files that should be served by apache
Alias /redmine/images C:/Repositories/redmine/public/images/
Alias /redmine/stylesheets C:/Repositories/redmine/public/stylesheets/
Alias /redmine/javascript C:/Repositories/redmine/public/javascript/
# Remove the following on public sites as this is insecure
Alias /redmine/plugin_assets C:/Repositories/redmine/public/plugin_assets/
Alias /redmine/help C:/Repositories/redmine/public/help/
</IfModule>
# Make sure apache can see public and all subfolders - not suitable for public sites
<Directory "C:/Repositories/redmine/public/">
Allow from all
Order allow,deny
</Directory>
Mongrel은 다음과 같이 설치됩니다.
mongrel_rails service::install --prefix /redmine -N redmine_prod -p 4000 -e production -c C:\Repositories\redmine
그것이 누군가를 돕기를 바랍니다. 처음에는 Apache + FastCGI 등을 설정하려고 시도했지만 더 소중한 머리카락을 잃었습니다. Windows 친화적이지 않습니다.
추신 : 나는이 pdf가 매우 유용한 참조를 발견했다 : http://www.napcsweb.com/howto/rails/deployment/railswithapacheandmongrel.pdf
/Damien
승객 (http://modrails.com) 구성하기가 매우 쉽기 때문에 FASTCGI에 대한 더 나은 대안입니다. 현재 가지고있는 것과 유사한 구성을 사용하여 레일 앱을 호스팅하는 데 사용하는 것이 좋습니다