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

Nginx部署Symfony应用:HTTP转HTTPS请求超时问题求助

Nginx下Symfony应用HTTP无法重定向到HTTPS,请求超时

我在Nginx服务器上部署了Symfony应用,想要实现所有HTTP请求自动重定向到HTTPS。当前网站通过HTTPS可以正常访问,但用HTTP访问时会触发超时错误。

以下是我的nginx.conf配置片段:

server {
    listen 80 default_server;
    server_name xxxxxx;
    return 301 https://$server_name$request_uri;
}

server {
    listen 8080;
    listen [::]:8080;
    root /home/site/wwwroot/public;
    index  index.php index.html index.htm;
    server_name  xxxxx; 

    location / {            
        try_files $uri /index.php$is_args$args;
    }

    # Disable .git directory
    location ~ /\.git {
        deny all;
        access_log off;
        log_not_found off;
    }

    # Add locations of phpmyadmin here.
    location ~ ^/index\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param HTTP_PROXY "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_intercept_errors on;
        fastcgi_connect_timeout         300; 
        fastcgi_send_timeout           3600; 
        fastcgi_read_timeout           3600;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }

    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;
}

用Wireshark分析HTTP请求的网络流量后,发现服务器完全没有响应HTTP请求,抓包内容如下:

TCP 66  [TCP Retransmission] 61814 → 80 [SYN] Seq=0 Win=64240 Len=0 
MSS=1460 WS=256 SACK_PERM

TCP 66  [TCP Retransmission] 61814 → 80 [SYN] Seq=0 Win=64240 Len=0 
MSS=1460 WS=256 SACK_PERM
....

恳请各位提供解决思路,谢谢!

内容的提问来源于stack exchange,提问作者user23522015

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 15:06:18