Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've installed nginx and transfer my server over to nginx (from apache). I made a subdomain which has SSL. My http:// works perfect.. But when I access it starts to download file. Yet any other url with https:// works fine such as

nginx default config:

server {
listen 443;
root /var/www/;
index index.php index.html index.htm default.html default.htm;

ssl on;
ssl_certificate /root/gamegambit.crt;
ssl_certificate_key /root/gamegambit.key;
ssl_client_certificate /root/gs_intermediate_ca.crt;

ssl_session_timeout 5m;

ssl_protocols SSLv3 TLSv1;
ssl_prefer_server_ciphers on;

## Default location
location / {
    try_files $uri $uri/ /index.php?q=$request_uri;


location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
  access_log        off;
  expires           30d;
  root /var/www/;
    location ~ .*.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 location ~ /.ht {
    deny  all;
 location ~ /.git {
    deny  all;
    location ~ /.svn {
        deny  all;
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
            return 403;
            error_page 403 /403_error.html;
# caching of files 
    location ~* \.(ico|pdf|flv)$ {
            expires 1y;
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
            expires 14d;

My /etc/nginx/fastcgi_params

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param SERVER_PROTOCOL $server_protocol; 
fastcgi_param SCRIPT_NAME $fastcgi_script_name; 
fastcgi_param PATH_INFO $fastcgi_script_name; 
fastcgi_param REQUEST_URI $request_uri; 
fastcgi_param DOCUMENT_URI $document_uri; 
fastcgi_param DOCUMENT_ROOT $document_root; 
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 QUERY_STRING $query_string; 
fastcgi_param REQUEST_METHOD $request_method; 
fastcgi_param CONTENT_TYPE $content_type; 
fastcgi_param CONTENT_LENGTH $content_length; 
fastcgi_param REDIRECT_STATUS 200;
share|improve this question
I suggest you turning debug to see what does the error log say. Also use location ~ \.php$ for more exact. – quanta Oct 16 '11 at 10:08

The location directive for php files should be like the following:

location ~ \.php$

Have a look t this tutorial for the full setup details and configuration settings:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.