Skip to content

Instantly share code, notes, and snippets.

@Mic92
Last active May 26, 2019 14:46
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Mic92/4091461 to your computer and use it in GitHub Desktop.
nginx configuration for the selfoss rss readerAs I don't get notification for gist comments, please add your modification to the wiki:https://github.com/SSilence/selfoss/wiki/nginx-configuration
# please make sure all directories/files in public/ are readable to your webserver, as well as data/favicons
# If it still doesn't work look into your log files at /var/log/nginx/rss.error.log
upstream backend { server unix:/var/run/php-fpm.sock; }
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/.*$ {
try_files $uri /data/$uri;
}
location ~* ^/(data\/logs|data\/sqlite|config\.ini|\.ht) {
deny all;
}
location / {
index index.php index.html index.htm;
try_files $uri /public/$uri /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
}
@makkes
Copy link

makkes commented Feb 20, 2013

What about favicons? I see requests to /favicons/SOMEICON.png which result in a 404.

@makkes
Copy link

makkes commented Feb 20, 2013

My solution looks like this:

location ~ ^/favicons/.*$ {
    try_files $uri /data/$uri;
}

@powerivq
Copy link

I think it is very necessary to disallow a visit to config.ini

location = /config.ini {
deny all;
}

@maco
Copy link

maco commented Mar 25, 2013

The CSS and JS aren't loading for me with this configuration. And nginx informed me that it has no idea what "main" means in the access_log line. Comparing to my other sites running on nginx, I don't have anything after the filename.

@Mic92
Copy link
Author

Mic92 commented Mar 30, 2013

Oh. I miss the comments! After writing this configuration snipped I stopped using selfoss. But well here are the updates.

@Mic92
Copy link
Author

Mic92 commented Mar 30, 2013

@maco I dropped the "main" tag as it is not available in debians/ubuntus nginx. Is the public directory readable?

@rafa3d
Copy link

rafa3d commented Jul 25, 2014

Just in case you have Selfoss inside a folder, would work:

// **********************************************************************

location ~ /selfoss(.*).php($|/) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/selfoss$1.php;
}

location ~ /selfoss(.*) {
autoindex on;
alias /usr/share/nginx/html/selfoss$1;
if (!-e $request_filename) { rewrite ^(.+)$ /selfoss/index.php?q=$1 last; }
}

// **********************************************************************

Keep in mind you would have to change the path address: /usr/share/nginx/html/selfoss to yours.

@Ramzus
Copy link

Ramzus commented Dec 16, 2014

two remarks :

  • your upstream backend embrace is not correct. The correct server unix line would be :

upstream backend { server unix:/var/run/php-fpm.sock; }

  • for those who doesn't have css and js loaded : don't forget to modify the base_url of your config.ini !

@wsokc
Copy link

wsokc commented May 26, 2019

two remarks :

  • your upstream backend embrace is not correct. The correct server unix line would be :

upstream backend { server unix:/var/run/php-fpm.sock; }

  • for those who doesn't have css and js loaded : don't forget to modify the base_url of your config.ini !

Just had this issue, what kind of url I should put in ?
Apparently in console i have found that all of the images and css not appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment