我正在尝试重定向http://foo.example.com到https://example.com:1234[实际上这不是我使用的端口 ;-) ]
这在 nginx 1.25 安装上曾经完美运行,但在另一台机器上的 1.24 上却无法运行
这是相关的服务器块(位于其自己的虚拟主机中):
server {
# listen for regular (i.e. non-secure) http traffic
listen 80;
# Make site accessible from http://foo.example.com:1234
server_name foo.example.com;
# Redirect so all traffic goes through secure route and specified port
return 301 https://example.com:1234;
}
“默认”服务器虚拟主机.conf 服务器块如下所示:
server {
# listen for regular (i.e. non-secure) http traffic
listen 80 default_server;
# Make site accessible from http://example.com:
server_name example.com:;
# Redirect so all traffic goes through secure route
# use address from server_name variable
return 301 https://$server_name$request_uri;
}
默认虚拟主机运行良好,但重定向不正常。
顺便说一句:这是在 Fedora 39 上,模块化存储库的弃用使得安装 nginx 1.25 变得更加困难
任何见解都将不胜感激。谢谢!