Drupal 8 as a Static Site: Add feed.rss to web server config and views

Submitted by nigel on Tuesday 13th November 2018
Fix Views RSS feeds paths
Taxonomy Term
Planet Feed

My objective here is to ensure that my existing /taxonomy/term/%/feed and /planet/feed links still work correctly so I won't lose any RSS feed subscribers to my website. As I have mentioned previously, Tome will automatically create an index.html page when there is no file extension on a path. So it's best to add extensions then! Navigate to /admin/structure/views and edit Taxonomy term then click the feed display. Click on the path and edit according to my first screenshot above and save. I also have a Drupal Planet feed which acts on my frontpage but with tag filters,  so I repeated those steps and added a feed.rss path to that too. 

We aren't done yet though - my web server config needs to be changed too so that the RSS pages can be served up correctly. 

nginx configuration
# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;
 
        # SSL configuration
 
        root {{ path_to_your_docroot }};
 
        server_name {{ your_server_name }};
 
        location ~ (/planet/feed|/taxonomy/term/\d+/feed) {
                index feed.rss;
        }
 
        location / {
 
                index index.html;
 
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
               deny all;
        }
}
Note that I have added a new location region in the configuration specifically for the feed.rss files. Here we are saying if the path is either /planet/rss or /taxonomy/feed/%/feed then ensure that feed.rss files are served and not index.html files.
Apache configuration
<VirtualHost *:80>
# change this to 443 is you are using ssl
 
  <Directory "{{ path_to_your_docroot }}/planet/feed">
	DirectoryIndex feed.rss
  </Directory>
  <Directory ~ "{{ path_to_your_docroot }}/taxonomy/term/[0-9]+/feed">
	DirectoryIndex feed.rss
  </Directory>
  ServerName {{ your_server_name }}
  DocumentRoot "{{ path_to_your_docroot }}"
  DirectoryIndex index.html
 
 
  # Comment out the block below for SSL
  #SSLEngine on
  #SSLCertificateFile "/path/to/www.example.com.cert"
  #SSLCertificateKeyFile "/path/to/www.example.com.key"
 
  <Directory "{{ path_to_your_docroot }}">
      AllowOverride All
  </Directory>
 
  # Logs
  Errorlog ${APACHE_LOG_DIR}/static.error.log
  CustomLog ${APACHE_LOG_DIR}/static.access.log combined
 
</VirtualHost>
The Apache configuration uses two new Directory directives. The second one contains a wildcard tilde and a regex to ensure that the path /taxonomy/term/%/feed is limited to numerics only. However I had another configuration problem - my Apache server was unaware of the .xml and .rss filename extensions, so wouldn't serve the content up. This was fixed by adding a filetype to the Apache configuration.
mods-available/mime.conf
AddType application/xml .xml .rss
Success!
Success

The picture above provides the evidence the fixes worked!