RSS-Bridge / rss-bridge

The RSS feed for websites missing it
https://rss-bridge.org/bridge01/
The Unlicense
7.34k stars 1.04k forks source link

Add example Caddy 2 config to documentation #3785

Open apogorzelska opened 1 year ago

apogorzelska commented 1 year ago

Is your feature request related to a problem? Please describe. I'm not sure how to correctly configure Caddy 2 to serve RSS-Bridge on my VPS (I'm relatively new to self-hosting).

Describe the solution you'd like Add an example Caddyfile to installation instructions in documentation.

Describe alternatives you've considered I tried googling but I didn't get a definitive answer on how to achieve it.

dvikan commented 1 year ago

im unfamiliar with caddy but i heard it's good

Bockiii commented 11 months ago

Never used Caddy because other solutions are easier if you have multiple docker containers which may not be websites running.

But since rssbridge is basically just a website which requires nothing special, try this in your caddyfile:

rssbridge.yourwebsite.url {
    reverse_proxy YOURRSSBRIDGECONTAINERNAME:80
}

the first entry is obviously your supposed subdomain. This defines what caddy should do when a request comes to this url. The reverse_proxy will only do that proxying. Proxy this to the name of your rssbridge container (use the docker "container_name" directive to define that in your compose file) and port.

If you want to "try something else", look at SWAG from LSIO or Cosmos UI (relatively new but I've been testing it for a while and its pretty cool. I also added rssbridge to it :) )

apogorzelska commented 11 months ago

Thank you for your answer, I'm sure if I was running RSS-Bridge with Docker that would work flawlessly. However, I'm not using Docker on my VPS. I installed RSS-Bridge through following commands:

apt install php-fpm php-mbstring php-simplexml php-curl
cd /var/www
git clone https://github.com/RSS-Bridge/rss-bridge.git

I then attempted my best to deduce from various sources how to translate RSS-Bridge's Nginx config to a Caddy config, and added the following to Caddyfile (I changed my domain to example.com for privacy):

rss-bridge.example.com {
    root * /var/www/rss-bridge
    php_fastcgi unix//run/php/php-fpm.sock {
    index index.php
    root /var/www/rss-bridge
    read_timeout 60s
    }
    file_server
}

I then run the following to make sure the Caddyfile doesn't have errors, and restarted Caddy:

cd /etc/caddy
sudo caddy fmt --overwrite
sudo caddy validate
systemctl restart caddy

However, when I try to go to rss-bridge.example.com, all I see is a blank page. I'm not sure what I'm doing wrong - am I perhaps missing some crucial basic step in running a PHP site in general that would be obvious to a PHP developer, or is the config still wrong in some way?

I would appreciate any further help.

apogorzelska commented 11 months ago

Further update: Looks like the page loads now! For the folks facing similar problems in setting up RSS-Bridge, know that I changed two things (but I think 1 was the one that was the actual issue):

1) I changed permissions for the rss-bridge folder:

chmod -R a+rwx /var/www/rss-bridge

2) I switched up the socket for a port (apparently the socket thingy can be troublesome in some cases?), with following steps:

I changed up the following config:

nano /etc/php/7.4/fpm/pool.d/www.conf

by switching the socket to a port, like so:

;listen = /run/php/php7.4-fpm.sock
listen = 127.0.0.1:7345

After saving, I made sure to refresh fpm:

systemctl restart php7.4-fpm 
systemctl status php7.4-fpm 

And then I changed the socket to a port in Caddyfile, and repeated the steps to check Caddyfile validity and restart Caddy:

rss-bridge.example.com {
        root * /var/www/rss-bridge
        php_fastcgi 127.0.0.1:7345 {
                index index.php
                root /var/www/rss-bridge
                read_timeout 60s
        }
        file_server
}
Bockiii commented 11 months ago

Giving everyone rwx is probably not a good practice for public facing websites.

If I was you, i would join the caddy discord and ask there if this is a good approach or if theres an easier way.

apogorzelska commented 10 months ago

After some figuring things out, in the end I set it up as following:

  1. I set up fpm to run as Caddy's system user, like so:

I edited following config:

nano /etc/php/7.4/fpm/pool.d/www.conf

by switching up the user and group to Caddy's:

user = caddy
group = caddy

After saving the config, I made sure to refresh fpm:

systemctl restart php7.4-fpm 
systemctl status php7.4-fpm 
  1. I changed RSS-Bridge folder permissions like so:
sudo chown -R caddy:caddy /var/www/rss-bridge
sudo chmod -R 2770 /var/www/rss-bridge

If I understand correctly, this way only the folder's owner user+group has access to the folder.

dvikan commented 10 months ago

there is recent changes to README.md related to this