2015-02-23 85 views
0

我有一個使用Spring Security進行登錄的Spring MVC應用程序。我使用Apache Webserver作爲代理和Tomcat。下面是我的/etc/apache2/sites-enabled/example.com.conf文件:Apache與Proxypass和Spring Security

ServerAdmin [email protected] 
ServerName example.com 
ServerAlias www.example.com 
DocumentRoot /var/www/example.com/public_html 

ProxyPreserveHost On 
ProxyRequests off 

ProxyPass /myapp/j_spring_security_check http://localhost:8080/myapp/j_spring_security_check 
ProxyPassReverse /myapp/j_spring_security_check http://localhost:8080/myapp/j_spring_security_check 
ProxyPass /myapp http://localhost:8080/myapp 
ProxyPassReverse /myapp http://localhost:8080/myapp 

這工作得很好,我能夠登錄到我的網站。但是,我必須使用http://example.com/myapp而不是http://example.com。如果我以後使用,它讓我看到:

Index of/

[ICO] Name Last modified Size Description 
[IMG] favicon.ico 2015-02-23 14:15 7.6K  

如果我修改example.com.conf文件被其他網站/職位的建議,我什麼也沒有和http://example.com帶我去http://example.com/myapp

ProxyPass /j_spring_security_check http://localhost:8080/j_spring_security_check 
ProxyPassReverse /j_spring_security_check http://localhost:8080/j_spring_security_check 
ProxyPass/http://localhost:8080/myapp 
ProxyPassReverse/http://localhost:8080/myapp 

有人可以幫忙嗎?謝謝。

編輯:

下面是我在我按How to set the context path of a web application in Tomcat 7.0創建 「〜/ Apache的Tomcat的7.0.52/conf目錄/卡塔利娜/本地主機」 文件夾中的ROOT.xml。

<Context 
    docBase="/home/anuj/webapps/prod-prop-3" 
    path="" 
    reloadable="true" 
/> 

但是,當我嘗試這樣做,http://example.com帶我去http://example.com/login,給了錯誤:

The requested URL /login was not found on this server.

什麼是這裏的問題,可以有人幫忙嗎?

回答

0

修改httpd.conf具有以下代理服務器設置:

ProxyPass /j_spring_security_check http://localhost:8080/j_spring_security_check ProxyPassReverse /j_spring_security_check http://localhost:8080/j_spring_security_check ProxyPass /myapp http://localhost:8080/

ProxyPassReverse /myapp http://localhost:8080/

+0

它不工作。如果我嘗試http://example.com,我會得到索引列表。如果我嘗試http://example.com/myapp,則不顯示任何內容。 – AAgg 2015-02-23 13:41:34