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

**URL:** <https://forum.yunohost.org/t/forward-a-specific-domain-to-another-server-on-the-network-using-yunohosts-nginx/25292>\
**Category:** Support\
**Tags:** nginx, english\
**Created:** [June 25, 2023, 7:17pm UTC](https://forum.yunohost.org/t/forward-a-specific-domain-to-another-server-on-the-network-using-yunohosts-nginx/25292 "2023-06-25T19:17:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![systeminfo](https://forum.yunohost.org/user_avatar/forum.yunohost.org/systeminfo/32/8172_2.png) [@systeminfo](https://forum.yunohost.org/u/systeminfo)\
**Post date:** [June 25, 2023, 7:17pm UTC](https://forum.yunohost.org/t/forward-a-specific-domain-to-another-server-on-the-network-using-yunohosts-nginx/25292/1 "2023-06-25T19:17:03Z")

</div>

### 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](http://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: [https://stackoverflow.com/questions/42202758/nginx-redirect-subdomain-to-seperate-server-ip](https://stackoverflow.com/questions/42202758/nginx-redirect-subdomain-to-seperate-server-ip)

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!

---

<div class="post-metadata">

**Author:** ![Aleks](https://forum.yunohost.org/user_avatar/forum.yunohost.org/aleks/32/1704_2.png) [@Aleks](https://forum.yunohost.org/u/Aleks)\
**Post date:** [June 25, 2023, 10:34pm UTC](https://forum.yunohost.org/t/forward-a-specific-domain-to-another-server-on-the-network-using-yunohosts-nginx/25292/2 "2023-06-25T22:34:19Z")

</div>

You probably want to use the redirect app [GitHub - YunoHost-Apps/redirect\_ynh: Redirection app for YunoHost](https://github.com/YunoHost-Apps/redirect_ynh) with “private proxy” / proxy\_pass / a.k.a reverse proxy

---

<div class="post-metadata">

**Author:** ![systeminfo](https://forum.yunohost.org/user_avatar/forum.yunohost.org/systeminfo/32/8172_2.png) [@systeminfo](https://forum.yunohost.org/u/systeminfo)\
**Post date:** [June 26, 2023, 12:04am UTC](https://forum.yunohost.org/t/forward-a-specific-domain-to-another-server-on-the-network-using-yunohosts-nginx/25292/3 "2023-06-26T00:04:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![systeminfo](https://forum.yunohost.org/user_avatar/forum.yunohost.org/systeminfo/32/8172_2.png) [@systeminfo](https://forum.yunohost.org/u/systeminfo)\
**Post date:** [June 26, 2023, 2:53pm UTC](https://forum.yunohost.org/t/forward-a-specific-domain-to-another-server-on-the-network-using-yunohosts-nginx/25292/4 "2023-06-26T14:53:55Z")

</div>

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

 ![image](https://forum.yunohost.org/uploads/default/original/2X/5/509c622b92c743f556fec0031f6345799d8c4981.png)

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

 ![image](https://forum.yunohost.org/uploads/default/original/2X/6/6a1f045bf495aac06a2ed8d7cd0f6e1bc833efe5.png)

I needed “private\_proxy.”

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

 ![image](https://forum.yunohost.org/uploads/default/original/2X/6/61ddcc2bcbd0e504e474c87d151bf1e086b3fa57.png)

---

<div class="post-metadata">

**Author:** ![systeminfo](https://forum.yunohost.org/user_avatar/forum.yunohost.org/systeminfo/32/8172_2.png) [@systeminfo](https://forum.yunohost.org/u/systeminfo)\
**Post date:** [June 26, 2023, 3:22pm UTC](https://forum.yunohost.org/t/forward-a-specific-domain-to-another-server-on-the-network-using-yunohosts-nginx/25292/5 "2023-06-26T15:22:58Z")

</div>

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.

 ![image](https://forum.yunohost.org/uploads/default/original/2X/0/01beaa9bca396bd65fbac52c16149dfee7b0a479.png)

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](https://github.com/YunoHost-Apps/redirect_ynh)
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:

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

```

I kept [mydomain.com](http://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.

---

<div class="post-metadata">

**Author:** ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)\
**Post date:** [July 11, 2023, 3:23pm UTC](https://forum.yunohost.org/t/forward-a-specific-domain-to-another-server-on-the-network-using-yunohosts-nginx/25292/6 "2023-07-11T15:23:51Z")

</div>

Closed on July 11, 2023, 3:23pm UTC

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