doumu6997 2015-06-17 20:07
浏览 75
已采纳

Roundcube - Nginx不会自动重定向到.php文件

EDITED!

I set up a mail server on Debian 7 with Nginx, Postfix, Postfixadmin, Dovecot and Roundcube.

I tried to create an alias to use the SSL certificate of my domain example.org (of course, the domain here is an example) for the webmail. When accessing the following URL https://example.org/support/webmail/ - Nginx doesn't redirect to the index.php file and I get the following message 403 Forbidden. It only works if I manually add a .php file at the end of the URL.

Here's my configuration:

server {
    listen 80;
    server_name example.org;
    return 301 https://$server_name$request_uri;
}

server {
    listen 80;
    server_name www.example.org;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    ssl on;

    server_name example.org;
    root /var/www/soon;

    server_tokens off;

    ssl_certificate /etc/ssl/certs/example.org.certchain.crt;
    ssl_certificate_key /etc/ssl/private/example.org.key;

    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 10m;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256;
    ssl_prefer_server_ciphers on;

    # HSTS
    add_header Strict-Transport-Security max-age=15768000;

    location /support/webmail/ {
        alias /var/www/webmail/;
        autoindex off;

        location ~ \.php$ {
          include       /etc/nginx/fastcgi_params;
          # include       fastcgi_params;
          fastcgi_pass  unix:/var/run/php5-fpm.sock;
          fastcgi_index index.php;
          # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param SCRIPT_FILENAME $request_filename;
        }
    }
}

Thank you. :)

  • 写回答

2条回答 默认 最新

  • doulin8374 2015-06-18 15:46
    关注

    Solved.

    Here's the configuration that works for me:

    server {
        listen 80;
        server_name example.org;
        return 301 https://$server_name$request_uri;
    }
    
    server {
        listen 80;
        server_name www.example.org;
        return 301 https://$server_name$request_uri;
    }
    
    server {
        listen 443 ssl;
        ssl on;
    
        server_name example.org;
        root /var/www/soon;
    
        server_tokens off;
    
        ssl_certificate /etc/ssl/certs/example.org.certchain.crt;
        ssl_certificate_key /etc/ssl/private/example.org.key;
    
        ssl_session_cache shared:SSL:20m;
        ssl_session_timeout 10m;
    
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256;
        ssl_prefer_server_ciphers on;
    
        # HSTS
        add_header Strict-Transport-Security max-age=15768000;
    
        location /support/webmail/ {
            alias /var/www/webmail/;
            autoindex off;
            index index.php;
    
            location ~ \.php$ {
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              include       /etc/nginx/fastcgi_params;
              fastcgi_pass  unix:/var/run/php5-fpm.sock;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $request_filename;
            }
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Qt安装后运行不了,这是我电脑的问题吗
  • ¥15 数据量少可以用MK趋势分析吗
  • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
  • ¥15 大智慧怎么编写一个选股程序
  • ¥100 python 调用 cgps 命令获取 实时位置信息
  • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
  • ¥15 C语言使用vscode编码错误
  • ¥15 用KSV5转成本时,如何不生成那笔中间凭证
  • ¥20 ensp怎么配置让PC1和PC2通讯上
  • ¥50 有没有适合匹配类似图中的运动规律的图像处理算法