【发布时间】:2018-06-12 03:42:01
【问题描述】:
我有一个应用程序部署到 Elastic Beanstalk,其 Tomcat 容器使用 Google OpenID Connect 进行身份验证。我想将所有http 请求重定向到https,为此我在.ebextensions 的文件中有以下mod_rewrite 配置-
files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: root
group: root
content: |
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
Google OAuth2 凭据控制台将 https://example.com/j_security_check 作为授权重定向 URL。当请求example.com 或https://example.com 时,配置工作正常,因此应用程序被重定向到提到的授权URL。
但是,当明确请求 http - http://example.com - 应用程序被重定向到 https 但 port 80 仍在使用中。然后授权的重定向 URL 变为https://example.com:80/j_security_check,我得到Error: redirect_uri_mismatch。
如何将明确的http 请求重定向到https,并将端口更改为443?主要目标是匹配提到的授权重定向 URL。如果可能的话,我想用.ebextensions 配置文件或类似的解决方案来实现它。
【问题讨论】:
标签: apache amazon-web-services mod-rewrite amazon-elastic-beanstalk google-openid