Forward a specific domain to another server on the network using yunohost's nginx?

My YunoHost server

Hardware: 64 Bit Thin Machine with random i7
YunoHost version: 11.1.21.4
I have access to my server : Through SSH | through the webadmin | direct access via keyboard / screen
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : yes

This is a complex question and is more a nginx question than a yunohost question, but with yunohost’s specific implementation of nginx I felt this was the place to ask.

I already have a nextcloud server running on my network that uses port 80 and 443. As such, I am using ports 8080 and 8443 for the yunohost instance.

However, this is less than ideal, especially since this breaks lots of links in yunohost since it does not expect the user needs to have ports in the IP address.

I could switch it to be forwarding over to the yunohost instance. Then, I was thinking I could use nginx to forward my nextcloud domain files.mydomain.com to my server’s IP over LAN. This is an https connection, not HTTP. Would this be doable? Would SSL certs still work?

This stack overflow issue talks about this: nginx redirect subdomain to seperate server ip - Stack Overflow

If it was to work, where would I be saving this conf file? There are many conf files in nginx/conf.d/ so I’m not sure which I’d use.

I’d also need it to not add too much overhead or stress the yunohost system too much. We have six users that upload and download large files and folders full of photos daily and we really cant sacrifice performance.

If that is not an option, is it possible to make yunohost aware that custom ports are required in its URLs?

Cheers!

You probably want to use the redirect app GitHub - YunoHost-Apps/redirect_ynh: Redirection app for YunoHost with “private proxy” / proxy_pass / a.k.a reverse proxy

That’s perfect! I don’t know why I didn’t think of adding an app!

@Aleks any ideas on what redirect type I should be using?

EDIT: Looks like that’s suppose to be a dropdown.

I needed “private_proxy.”

However, now I am getting an “Error: Too many redirects” message:

Solution was to disable https redirect in the apache config file for Nextcloud on the server hosting nextcloud. To do this I edited the file located in /etc/apache2/sites-available/nextcloud.conf
I believe it was 2 lines near the bottom of the file. This was added by certbot.

Logging in via the website now works! However, I could not sign in via any apps.

This was fixed by adding overwrite protocol to the nextcloud config.

Now everything is working! To list all the steps I took for future people:

  1. Change port forwarding to forward to yunohost
  2. Install GitHub - YunoHost-Apps/redirect_ynh: Redirection app for YunoHost
  3. Set up redirect_ynl to forward to my nextcloud server over HTTP
  4. Add the local ip of the yunohost server to the trusted domains config in /var/www/nextcloud/config/config.php
  5. Add some overwrite protocol to config.php (to keep apps happy)
  6. Remove https redirect lines from nextcloud.conf (if present)
  7. restart apache2
  8. Sign out and Sign in to nextcloud apps!

Config.php had the following changes made to the trusted domains section:

  'trusted_domains' =>
  array (
    0 => 'mydomain.com',
    1 => '192.168.0.localipaddressofyunohost',
  ),
  'overwrite.cli.url' => 'https://mydomain.com',
  'overwriteprotocol' => 'https',

I kept mydomain.com there as a trusted domain so if yunohost goes down I can port forward directly to the nextcloud server again, run certbot, and be good to go.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.