You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nginx 1.24配置301重定向失效问题求助

Nginx 1.24配置301重定向失效问题求助

各位大佬好,想请教个Nginx重定向的问题:我本来要把http://foo.example.com重定向到https://example.com:1234(实际用的不是这个端口哈😉),之前在Nginx 1.25版本的机器上配置完全没问题,但换了台装了1.24版本的机器后,这个重定向就失效了。

下面是我配置的相关server块,这个是单独的虚拟主机配置:

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块是这样的(后面内容没写完):

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 a...

麻烦帮忙看看哪里出问题了,谢谢!

备注:内容来源于stack exchange,提问作者FBachofner

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 10:19:32