RSS Feed not working Drupal + Nginx + Boost Configuration

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Baber Javed's picture

Hi,
I have been trying to figure this out but unable to fix this issue. I have setup and enabled Boost on Nginx and it works fine now but I cannot access my rss.xml file. It throws Nginx 404 Page not found error

Here is my Nginx Configuration file

server {
listen 80;
server_name www.pakreviews.com;
rewrite ^(.*) http://pakreviews.com$1 permanent;
}

server {
server_name www.pakreviews.com;
access_log /www/projects/pakreviews/logs/access.log;
error_log /www/projects/pakreviews/logs/error.log;

root /www/projects/pakreviews;

charset utf-8;

# search for already compressed files
gzip_static on;
gzip on;

# some images have no mime type
default_type image/jpeg;

# Buffers definition. allows of up to 260k to be passed in memory.
client_body_buffer_size 1m;
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 8 32k;

# 404 generated from php can be rather slow. Uncomment with care
#error_page 404 /index.php;

# disallow access to version control directory, but return 404, not to disclose information
location /.git {
return 404;
}

# robots.txt is important for search engines
location /robots.txt {
access_log off;
}

# This is mostly based on Drupal's stock .htaccess
location ~* ^.+(.(txt|engine|inc|info|install|module|profile|po|sh|.sql|theme|tpl(.php)?|xtmpl)|code-style.pl|/Entries.|/Repository|/Root|/Tag|/Template)$ {
return 404;
}

# serve imagecache files directly or redirect to drupal if they do not exist
location ~* imagecache {
access_log off;
expires 30d;
try_files $uri @drupal;
}

# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|swf|flv)$ {
access_log off;
expires 30d;
}

# This rewrites pages to be sent to PHP processing
location @drupal {
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}

location / {
try_files $uri @cache;
}

# This will try to see if we have a boost file in place. no harm done if this is not used
location @cache {
# queries, drupal cookies, or not GET methods, all require PHP processing.
if ($query_string ~ ".+") {
return 405;
}
if ($http_cookie ~ "DRUPAL_UID" ) {
return 405;
}
if ($request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
error_page 405 = @drupal;

# Drupal uses 1978 - I am 4 years older than Dries :)
add_header Expires "Tue, 22 Sep 1974 08:00:00 GMT";       
add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
try_files /cache/normal/$host/${uri}_.html /cache/perm/$host/${uri}_.css /cache/perm/$host/${uri}_.js /cache/$host/0$uri.html /cache/$host/0${uri}/index.html @drupal;

}

# only a few php files are allowed, this increases the overall server security
location ~* ^/(index|boost_stats|cron|xmlrpc).php$ {
fastcgi_pass 127.0.0.1:49232;
fastcgi_index index.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_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;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;  
fastcgi_param SCRIPT_FILENAME /www/projects/pakreviews$fastcgi_script_name; # same path as above

}

# internal pages are protected with a simple htpasswd
location ~* ^/(install|update|memcached|apc|info).php$ {
fastcgi_pass 127.0.0.1:49232;
fastcgi_index index.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_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;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;
fastcgi_param SCRIPT_FILENAME /www/projects/pakreviews$fastcgi_script_name; # same path as above

}

location ~* ^.+.php$ {
return 404;
}

}

Comments

This location is causing the

brianmercer's picture

This location is causing the problem:

# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|swf|flv)$ {
access_log off;
expires 30d;
}

It will match rss.xml and cause a 404.

Either remove xml from that list or add other locations like this:

location = /rss.xml {
  rewrite ^ /index.php?q=rss.xml;
}

location = /sitemap.xml {
  try_files $uri /index.php?q=sitemap.xml;
}

Typical .xml addresses might be static or they might be dynamically generated through Drupal. CKeditor uses a static .xml file, but then rss.xml needs to be dynamically generated. Also sitemap.xml would be generated dynamically through Drupal if you're using the Drupal sitemap module or it might be a static file if you're using some non-Drupal script to generate your sitemaps.

Probably need to file a bug with yhager also.

Edit: I recall FCKeditor using an xml file, but now that I check my sites, I don't see CKEditor 3.4 using one. Easiest to just remove xml from that list of static files unless you know your site uses static xml files in some way.

yeah you were right on Brian.

Baber Javed's picture

yeah you were right on Brian. The yhager script ts setup to serve rss files statically. Removing the xml from the list solved the issue
Thanks a heap!