大网数据广告活动
服务器运维问答

Nginx listening to 443 in order to redirect a domain without an ssl certificate

· 52CE 我爱测

I got an ssl certificate for newdomain.org.il But some requests (images) I'm getting from https://olddomain.org.il (Since client has schemeless links, which is ok) I can easily redirect non https requests: server { listen 80; ser…

问题原文

原帖链接 · alonisser · CC BY-SA 3.0

I got an ssl certificate for newdomain.org.il

But some requests (images) I'm getting from https://olddomain.org.il

(Since client has schemeless links, which is ok)

I can easily redirect non https requests:

server {
     listen      80;

     server_name  www.olddomain.org.il olddomain.org.il;
     return 301 https://newdomain.org.il$request_uri;
}

But that won't catch requests from old domain with https

but if I add a listen clause for olddomain

server {
     listen      80;
     listen      443 ssl;

     server_name  www.olddomain.org.il olddomain.org.il;
     return 301 https://newdomain.org.il$request_uri;
 }

requests would get an sslError since hostname won't match the certificate domain.

Any workaround this in nginx? (I know I can workaround and another ssl certificate for old domain or with a code change preventing those legacy urls to exists, but Since this is a migration process from a legacy app, I really don't want to.

已采纳解答

原帖链接 · Ginnungagap · CC BY-SA 3.0

Short answer, no.

The whole point of HTTPS is to ensure the security of the connection, you need to have a certificate for NGINX to load, and it has to be valid for the browsers to accept loading resources from it. The only way to keep the resources on the old domain and serve them over HTTPS is to add a valid certificate for the old domain.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-12-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。