I am running drupal on nginx and I have the services module installed (https://www.drupal.org/project/services). I have some views enabled to get and edit web content via http requests. The url's are of type http:/base_url/end_point/view. It works pretty well on apache, but in nginx I get a 404 error specifically with those urls (the rest of drupal pages are correctly displayed).

In apache I used the following configuration on /etc/apache2/sites-available/000-default.conf to get those links working

<VirtualHost *:80>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

<Directory /var/www/>
    Options FollowSymLinks
    AllowOverride All 
    Allow from all
    Options Indexes FollowSymLinks                                

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined


In nginx I have tried with disable_symlinks off, but it does not work. The following is the configuration at /etc/nginx/sites-available/default

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
        autoindex off;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
        disable_symlinks off;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    autoindex off;
    # With php5-cgi alone:
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    disable_symlinks off;

How should I configure nginx to be able to follow the services links?

  • I don't think symlinks is the issue. You need to send those special paths to the drupal controller /index.php. Change try_files to try_files $uri $uri/ /index.php;. That will process the URL rather than rejecting it with a 404 error. – Richard Smith Nov 30 '15 at 21:59
  • Now I get the message "file not found". Any ideas? – Nicolás Arias Dec 1 '15 at 19:43
  • Do you have Drupal installed into a subfolder?,In which case you would need /drupalpath/index.php for that last element. – Richard Smith Dec 1 '15 at 20:05

Your Answer

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

Browse other questions tagged or ask your own question.