0

I installed Roundcube fresh on Debian stretch with Nginx and it works fine on a IP Adresse with /webmail or domain/webmail. But as i tried to let it run on the root of a Domain php is offering the PHP file as Download. How can i get access to it on the root of the domain?

This is my Nginx config that will not work and i get the PHP File as Download

server {
        listen *:80;

        listen *:443 ssl;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_certificate /var/www/clients/client0/web1/ssl/xxxxl.de.crt;
        ssl_certificate_key /var/www/clients/client0/web1/ssl/xxxx.de.key;

        server_name xxx.de ;
        root /usr/share/roundcube;

        index index.html index.htm index.php index.cgi index.pl index.xhtml;


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

           location ~ ^/(bin|SQL|config|temp|logs)/ {
              deny all;
           }

   location ~* \.php$ {
                        fastcgi_param  QUERY_STRING            $query_string;
                       fastcgi_param   REQUEST_METHOD          $request_method;
                       fastcgi_param   CONTENT_TYPE            $content_type;
                       fastcgi_param   CONTENT_LENGTH          $content_length;

                       fastcgi_param   SCRIPT_FILENAME         $request_filename;
                       fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
                       fastcgi_param   REQUEST_URI             $request_uri;
                       fastcgi_param   DOCUMENT_URI            $document_uri;
                       fastcgi_param   DOCUMENT_ROOT           $document_root;
                       fastcgi_param   SERVER_PROTOCOL         $server_protocol;

                       fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
                       fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

                       fastcgi_param   REMOTE_ADDR             $remote_addr;
                       fastcgi_param   REMOTE_PORT             $remote_port;
                       fastcgi_param   SERVER_ADDR             $server_addr;
                       fastcgi_param   SERVER_PORT             $server_port;
                       fastcgi_param   SERVER_NAME             $server_name;

                       fastcgi_param   HTTPS                   $https;

                       # PHP only, required if PHP was built with --enable-force-cgi-redirect
                       fastcgi_param   REDIRECT_STATUS         200;
                       # To access SquirrelMail, the default user (like www-data on Debian/Ubuntu) must be used
                       fastcgi_pass unix:/var/lib/php7.0-fpm/apps.sock;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       fastcgi_buffer_size 128k;
                       fastcgi_buffers 256 4k;
                       fastcgi_busy_buffers_size 256k;
                       fastcgi_temp_file_write_size 256k;
   }

}

But if i put int in a directory (change the root to /usr/share/ and add the code below) i will gain Access to Roundcube

location /{
               location ~ ^/roundcube/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_param   QUERY_STRING            $query_string;
                       fastcgi_param   REQUEST_METHOD          $request_method;
                       fastcgi_param   CONTENT_TYPE            $content_type;
                       fastcgi_param   CONTENT_LENGTH          $content_length;

                       fastcgi_param   SCRIPT_FILENAME         $request_filename;
                       fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
                       fastcgi_param   REQUEST_URI             $request_uri;
                       fastcgi_param   DOCUMENT_URI            $document_uri;
                       fastcgi_param   DOCUMENT_ROOT           $document_root;
                       fastcgi_param   SERVER_PROTOCOL         $server_protocol;

                       fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
                       fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

                       fastcgi_param   REMOTE_ADDR             $remote_addr;
                       fastcgi_param   REMOTE_PORT             $remote_port;
                       fastcgi_param   SERVER_ADDR             $server_addr;
                       fastcgi_param   SERVER_PORT             $server_port;
                       fastcgi_param   SERVER_NAME             $server_name;

                       fastcgi_param   HTTPS                   $https;

                       # PHP only, required if PHP was built with --enable-force-cgi-redirect
                       fastcgi_param   REDIRECT_STATUS         200;
                       # To access SquirrelMail, the default user (like www-data on Debian/Ubuntu) must be used
                       #fastcgi_pass 127.0.0.1:9000;
                       fastcgi_pass unix:/var/lib/php7.0-fpm/apps.sock;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       fastcgi_buffer_size 128k;
                       fastcgi_buffers 256 4k;
                       fastcgi_busy_buffers_size 256k;
                       fastcgi_temp_file_write_size 256k;
               }
               }
    ```

How can i access Roundcube directly from the root of the TLD?

Deex
  • 317
  • 2
  • 13
  • Getting the PHP file as a download instead of running (compiling) it means that you have problems with your Nginx configuration. What versions are you using at the moment? Did you changed something recently? – Maurice Jun 21 '19 at 10:03
  • Hey Maurice, it is a clean new installation. PHP Info Files are working. I'm using nginx/1.10.3 – Deex Jun 21 '19 at 12:27

1 Answers1

0

Okay here the resolution. It's a bit wierd but it was a Chrome Bug with the Cache! While i did setup the VHOST.conf i likely made something wrong and the PHP File was Downloaded in Chrome. For unknown Reason chromes cache was not refreshed within days and he offered me the Download again and a again. The resolution was to clear Chromes Cache / Use a different browser. I'm not going deeper in chrome and check why in this particular download case chrome dit not refresh the cache.

Deex
  • 317
  • 2
  • 13