【问题标题】:Apache with Proxypass and Spring Security带有 Proxypass 和 Spring Security 的 Apache
【发布时间】:2023-03-06 17:01:01
【问题描述】:

我有一个使用 Spring Security 进行登录的 Spring MVC 应用程序。我使用 Apache Webserver 作为代理和 Tomcat。下面是我的 /etc/apache2/sites-enabled/example.com.conf 文件:

ServerAdmin admin@example.com
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/Catalina/localhost”文件夹中的ROOT.xml。

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

但是当我尝试这个时,http://example.com 把我带到了http://example.com/login 并给出了错误:

在此服务器上找不到请求的 URL /login。

这里有什么问题,有人可以帮忙吗?

【问题讨论】:

    标签: spring apache tomcat spring-security proxypass


    【解决方案1】:

    使用以下代理设置修改 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/

    【讨论】:

    • 它不起作用。如果我尝试example.com,我会得到索引列表。如果我尝试example.com/myapp,它不会显示任何内容。
    猜你喜欢
    • 1970-01-01
    • 2011-01-27
    • 2021-09-16
    • 2018-05-22
    • 2018-01-29
    • 2017-07-22
    • 2011-09-28
    • 2017-10-02
    • 1970-01-01
    相关资源
    最近更新 更多