4

Having Drupal 7 on nginx with enabled clean urls. nginx config:

location @drupal {
rewrite ^/(.*)$ /index.php?q=$1 last;
}

When trying to run tests getting message:

You are not authorized to access this page.

Looks like Drupal cant resolve correctly /batch?op=start&id=28 path. Tests running ok if clean urls disabled.

Any advise on nginx or drupal config to resolve this?

1

You should rewrite Drupal 7 URLs using rewrite ^ /index.php last;. The more complete setup is (copied from my development setup):

server {
  listen 80;
  listen [::]:80;

  root [...];
  index index.php;
  server_name [...];

  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  # Deny all attempts to access hidden files
  location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
  }

  location / {
    try_files $uri $uri/ @rewrite;
  }

  location @rewrite {
    # Some modules enforce no slash (/) at the end of the URL
    # Else this rewrite block wouldn't be needed (GlobalRedirect)
    rewrite ^ /index.php last;
  }

  # pass the PHP scripts to FastCGI server listening on my unix socket
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 16k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_read_timeout 1200;
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
  }

  client_max_body_size 100M;

  location ~ ^/sites/.*/files/styles/ {
    try_files $uri @rewrite;
  }

  location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff|ttf|svg|eot)$ {
    expires max;
    log_not_found off;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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