【发布时间】:2019-06-13 11:17:39
【问题描述】:
我有 3 个 spring-boot 应用程序:
- 正面(用弹簧靴包裹的角度):8084
- 资源(弹簧靴):8082
- 身份验证(spring-boot spring security):8081。
这是我的虚拟主机:
<VirtualHost *:80>
ServerName www.website.com
Redirect / https://www.website.com/
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.website.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLProxyEngine on
ServerName www.website.com
ProxyPass /auth https://127.0.0.1:8081
ProxyPassReverse /auth https://127.0.0.1:8081
ProxyPass /api https://127.0.0.1:8082
ProxyPassReverse /api https://127.0.0.1:8082
ProxyPass / https://127.0.0.1:8084/
ProxyPassReverse / https://127.0.0.1:8084/
SSLCertificateFile /etc/letsencrypt/live/www.website.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.website.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
这是有效的,当调用 https://www.website.com/auth/oauth/authorize 端点时,我被重定向到 https://www.website.com/auth/login 并且我看到了我的登录表单。
问题是 jquery 或 css 等资源未加载,因为它试图通过 URL https://www.website.com/resources/jquery.min.js 访问它们(尽管它应该是 https://www.website.com/auth/resources/jquery.min.js)。
我在这里尝试了解决方案:Spring-boot with embedded Tomcat behind Apache proxy 所以我有虚拟主机:
<VirtualHost *:443>
SSLEngine on
SSLProxyEngine on
ProxyPreserveHost On
ServerName www.website.com
ProxyPass /auth https://127.0.0.1:8081
ProxyPassReverse /auth https://127.0.0.1:8081
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
ProxyPass /api https://127.0.0.1:8082
ProxyPassReverse /api https://127.0.0.1:8082
ProxyPass / https://127.0.0.1:8084/
ProxyPassReverse / https://127.0.0.1:8084/
SSLCertificateFile /etc/letsencrypt/live/www.website.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.website.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
我已经添加了
server.use-forward-headers=true
在 application.properties 中。
但是当 https://www.website.com/auth/oauth/authorize 被调用时,我被重定向到 https://www.website.com/login -> /auth 部分丢失了,所以我得到了 404。
不确定我应该设置什么以及在哪里进行设置?
【问题讨论】:
标签: spring-boot spring-security reverse-proxy vhosts mod-proxy