All in one system

Hi guys,

So I have a raspberry pi 3 B+ and what I am trying to do is set up more than one web server on my pi, in this case, pihole and nextcloud, everything else I add works without any conflicts.

From what I have read I need something like a reverse proxy? Does anyone have any experience with this? Or are there any alternatives to achieve the same thing.

I did once setup a reverse proxy using Nginx, and docker behind a single IP. Made a video about it, you can watch this here

Sorry, it is a bit rough (and long) but it gets the job done. Tag me if you have any more questions. :slight_smile:

Yes. Best option IMO would be Nginx.

Super simple.

Docker seems to be overkill for this project. As long as OP isn’t running into port conflicts, there’s no need to use containers.

3 Likes

Agreed.

1 Like

Thanks for the quick reply’s!

I did have a go with NGINX reverse proxy, but I just could not get it to work. Mainly I think it is to do with having lighttpd for pihole, apache2 for nexcloud and Nginx as the reverse proxy. Only one of them would run in one instance because they all use port 80, So if I run Nginx the other services would stop.

Okay, for that, docker might be a good solution. I know pihole and nextcloud both offer containers.

The other option would be to edit the configs for lighttpd and apache to have them listen on different ports.

1 Like

Ok but would that mean I would have to use the IP of my pi plus the port numbers to get to different web services?

Why not just add a second ip address to your pi’s interface and have nextcloud listen on port 80 on one address for pihole and port 80 on the other address for nextcloud?

Nope, you could definitely use nginx to redirect it, so it would be like ip.of.pi.3/nextcloud

This is another option.

That would be pretty cool

I did try docker, it was pretty difficult to find the right configuration for next cloud and the tweaks that I could make to have both systems run together simultaneously.

It’s pretty simple, I run nextcloud and roundcube off the same nginx box. Each listens on port 80/443 on a different ip:

/etc/nginx/sites-available/nextcloud
server {
    listen 10.0.0.196:80;
    listen [fd00:8801:2909:6000::f27c]:80;
    server_name nextcloud.danger-rocket.com;
        server_tokens off;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 10.0.0.196:443 ssl http2;
    listen [fd00:8801:2909:6000::f27c]:443 ssl http2;
    server_name nextcloud.danger-rocket.com;

...
/etc/nginx/sites-available/roundcube
server {
    listen [fd00:8801:2909:6000::0201]:80;
    server_name roundcube.danger-rocket.com;
        server_tokens off;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen [fd00:8801:2909:6000::0201]:443 ssl http2;
    server_name roundcube.danger-rocket.com;

    server_tokens off;

...
1 Like

Yer I’m pretty new to NGINX, only started using exploring it the past 4 hours.

I had no idea you could specify two different ip’s from in NGINX

When I was playing around with it I was trying to get it to work on the same ip with the same port for both.

I’d actually suggest haxproxy for this.

Why? because it does load balancing as well. And one day you’ll need to do load balancing at work. And… for doing load balancing, haproxy is way more advanced.

So why not learn it from the outset? :slight_smile:

I see how that works to a degree, are there any comprehensive guides that I could follow to configure this for my network?

If you are using lighttpd for pihole and apache for nextcloud, you may be able to add a second address to your pi’s interface and make two simple edits to the default configs to listen on specific addresses:

  1. add an address: ip address add 10.0.0.151 dev eth0 (I just piecked 10.0.0.151 and eth0 as examples. Use whatever you want for the ip in your subnet. It’s a good idea to pick something out of your dhcp server’s dynamic range so you don’t run into a conflict.)

  2. edit lighttpd config (probably /etc/lighttpd/lighttpd.conf) to include server.bind = (address1)

  3. edit your nextcloud apache config (maybe /etc/apache2/sites-available/nextcloud) to include listen (address2)

edit: After your edits, you would need to restart each service. systemctl restart lighttpd httpd would probably work.

1 Like

Thanks for that,

I finally got it to work, although it is a little temperamental. but I think there are some tweaks to be made.

I have not got it setup the same way as you (separate ip addresses per web server instance) but I have it setup with the same ip, just different ports for different services.

But I will be sharing them here in a form of a template as my contribution to the community. if anyone is looking to do the same think.

1 Like