Skip to content

nginx configuration

Jan Tojnar edited this page Jan 11, 2017 · 10 revisions

an example nginx configuration (thanks Mic92). See also this gist.

Please make sure all directories/files in public/ as well as data/favicons are readable to your web server.

If it still doesn't work look into your log files at /var/log/nginx/rss.error.log.

server {
    listen 80;
    listen 443 ssl;
    server_name rss.yourdomain.com;
    root /var/www/selfoss/;
    access_log /var/log/nginx/rss.access.log;
    error_log /var/log/nginx/rss.error.log;
    location ~* \ (gif|jpg|png) {
        expires 30d;
    }
    location ~ ^/(favicons|thumbnails)/.*$ {
        try_files $uri /data/$uri;
    }
    location ~* ^/(data\/logs|data\/sqlite|config\.ini|\.ht) {
        deny all;
    }
    location / {
        index index.php;
        try_files $uri /public/$uri /index.php$is_args$args;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
}

As an alternative which denies more stuff by default and is accessible from a subdirectory instead of separate domain, I added the following location block to my server block. selfoss is installed at /usr/share/webapps/selfoss

location /selfoss {
    root /usr/share/webapps;
    access_log /var/log/nginx/rss.access.log;
    error_log /var/log/nginx/rss.error.log;
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
    location ~ ^/selfoss/((favicons|thumbnails)/.+)$ {
        try_files /selfoss/data/$1 =404;
    }
    location ~ ^/selfoss/$ {
        index index.php;
    }
    location ~ ^/selfoss/(.+)$ {
        try_files /selfoss/public/$1 /selfoss/index.php$is_args$args;
    }
}

If ever you use nginx as front-end and apache as back end, see this page.