Mod rewrite 加密前重写https URL
我需要将类似*.lang.domain.com的URL重写为lang.domain.com,我使用nginx重写模块成功地完成了这项工作。我有通配符证书*.domain.com,它无法保护像test.lang.domain.com这样的4级域 主要问题是当用户键入Mod rewrite 加密前重写https URL,mod-rewrite,nginx,https,subdomain,Mod Rewrite,Nginx,Https,Subdomain,我需要将类似*.lang.domain.com的URL重写为lang.domain.com,我使用nginx重写模块成功地完成了这项工作。我有通配符证书*.domain.com,它无法保护像test.lang.domain.com这样的4级域 主要问题是当用户键入https://bla-bla.lang.domain.com在他们的浏览器中,他们首先会收到关于连接不安全的通知。然后他们需要单击“高级”并继续(不安全)。之后,它们将被重定向到。 所以我的问题是,在nginx中建立https连接之前
https://bla-bla.lang.domain.com
在他们的浏览器中,他们首先会收到关于连接不安全的通知。然后他们需要单击“高级”并继续(不安全)。之后,它们将被重定向到。
所以我的问题是,在nginx中建立https连接之前,是否可以进行重定向?还是可以在更高的层次上实现
server {
listen 80 default;
server_name www.domain.com domain.com *.domain.com;
if ($host ~* "^.+\.(.+\.domain\.com)$") {
set "$domain" "$1";
rewrite ^(.*)$ https://$domain$uri permanent;
}
return 301 https://$host$request_uri;
}
server {
listen 443 default;
server_name www.domain.com domain.com *.domain.com;
if ($host ~* "^.+\.(.+\.domain\.com)$") {
set "$domain" "$1";
rewrite ^(.*)$ https://$domain$uri permanent;
}
ssl on;
ssl_certificate /etc/ssl/domain.com/domain.com.ca-bundle;
ssl_certificate_key /etc/ssl/domain.com/domain.com.key;
include "conf.d/ssl_settings.default";
include "conf.d/redirect.ssl.default";
include "conf.d/logger_front.default";
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HTTPS on;
proxy_pass https://somestream;
}
}
在建立安全连接时发生重定向。所以不,你不能有一个重定向来处理你的特殊情况