Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example Caddy 2 config to documentation #3785

Open
apogorzelska opened this issue Oct 31, 2023 · 7 comments
Open

Add example Caddy 2 config to documentation #3785

apogorzelska opened this issue Oct 31, 2023 · 7 comments
Labels
Feature-Request Issue is a feature request

Comments

@apogorzelska
Copy link

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.

@apogorzelska apogorzelska added the Feature-Request Issue is a feature request label Oct 31, 2023
@dvikan
Copy link
Contributor

dvikan commented Nov 10, 2023

im unfamiliar with caddy but i heard it's good

@Bockiii
Copy link
Contributor

Bockiii commented Dec 11, 2023

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
Copy link
Author

apogorzelska commented Dec 16, 2023

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
Copy link
Author

apogorzelska commented Dec 16, 2023

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
  1. 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
Copy link
Contributor

Bockiii commented Dec 17, 2023

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
Copy link
Author

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
Copy link
Contributor

dvikan commented Dec 30, 2023

there is recent changes to README.md related to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-Request Issue is a feature request
Projects
None yet
Development

No branches or pull requests

3 participants