ssl - 谷歌负载均衡器重定向错误
问题描述
我正在尝试设置 Google 负载均衡器,但无法正常工作。它会产生 502 或 302 错误。
想要将 www 指向非 www,将 http 指向 https。
这是我的重写规则
SetEnvIf X-Forwarded-Proto https HTTPS=on
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs"
Include "/opt/bitnami/apps/letsencrypt/conf/httpd-prefix.conf"
<IfModule mod_proxy.c>
ProxyPass /.well-known !
</IfModule>
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^localhost
RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*)$ http://%1$1 [R=permanent,L]
<VirtualHost _default_:443>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^localhost
RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*)$ https://%1$1 [R=permanent,L]
Google 负载均衡器只有 1 个后端服务。后端为 HTTP 配置,前端为 HTTPS。
- 该实例可通过实例的 IP 和负载均衡器的 IP 访问
- www 到非 www 不起作用。
- Http 给出 404 错误。
- https 给出 502 / 302 错误。
重写规则都错了吗?
解决方案
推荐阅读
- r - 如何在 R 的数据集中对不同的变量使用相同的代码?
- python - 在对流层中添加对现有 sns 主题的订阅
- javascript - 如何访问数组中的数组
- ruby - 如何翻译 Rspec 中的默认消息?
- .htaccess - .htaccess 规则可以清理吗?
- html - 行堆叠时更改行中列的高度
- java - 我无法在 android 5.1 上获取通知图像,总是返回 null
- android - 从 Android 应用程序打印到本地以太网连接的打印机(不通过 Internet)
- firebase-authentication - 如何将 Firebase UI 身份验证按钮的位置从底部更改为中间
- c# - C# - 接收对象作为父接口并类型转换子类之一