Skip to content

nginx and apache configuration

bendem edited this page Oct 9, 2014 · 2 revisions

You can use this configuration if:

  • nginx is your web front-end,
  • apache is your web back-end,
  • nginx is accessed by the client through https:443,
  • apache is accessed by nginx through http:80.

If you don't use https just modify nginx conf to fit your needs (you should though)

/etc/nginx/sites-enabled/rss:

server {
    listen 80;
    server_name yourdn.root;
    rewrite ^ https://$server_name$request_uri? permanent;
}

server {
    listen 443;
    ssl on;
    ssl_certificate /etc/ssl/private/rss.pem;
    ssl_certificate_key /etc/ssl/private/rss.key;
    server_name yourdn.root;

    root /var/www/path/to/selfoss;

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

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

    location ~* ^/(data\/logs|data\/sqlite|config\.ini|\.ht|password) {
        deny all;
    }

    location / {
        **proxy_set_header X-Nginx-Scheme $scheme;**
        **proxy_set_header X-Forwarded-Port $server_port;**
        proxy_pass   http://127.0.0.1:8080/;
        include      /etc/nginx/proxy.conf;
    }
    access_log /var/log/nginx/rss-yourdn.root-access.log;
    error_log /var/log/nginx/rss-yourdn.root-error.log;
}

/etc/apache2/sites-enabled/rss:

<VirtualHost 127.0.0.1:8093>
    ServerAdmin contact@yourdn.root
    ServerName yourdn.root

    DocumentRoot /var/www/path/to/selfoss
    <Directory "/var/www/path/to/selfoss">
        Options FollowSymLinks
        Order Allow,Deny
        Allow From All
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/rss-yourdn.root-access.log combined
    ErrorLog ${APACHE_LOG_DIR}/rss-yourdn.root-error.log
</VirtualHost>