Nextcloud as subdomain of domain used on another external server?

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
I have a domain that I use for my website which is hosted by an offsite hosting service. I want to use that domain but to only direct subdomain.domain.com to my nextcloud installation on my personal server.

Should I be using DDNS and then CNAME (on my webhost's cpanel) to my DDNS address (duckdns)? I figured this part I got right.
What about Let's Encrypt? Should I be running that for my subdomain off my webhost's cpanel, or running it on my server?

I'm trying out this Guthub script, but not confident of what I'm really doing.. https://github.com/danb35/freenas-iocage-nextcloud
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,702
What about Let's Encrypt? Should I be running that for my subdomain off my webhost's cpanel, or running it on my server?
Nextcloud is running on your premises, not at the webhost, so I would expect that you will run letsencrypt locally too (since that's where you will need the certificate).

Only the DNS makes sense to be running outside.
 

samuel-emrys

Contributor
Joined
Dec 14, 2018
Messages
136
My setup is similar to what you're describing, and I wrote a manual installation guide for nextcloud. If you're interested in learning more about it, the link is in my signature. Ultimately, you need to create a DNS A record for your subdomain and point it to your home's public IP. You then need to route the request from your firewall/router to your nextcloud server. Depending on your DNS NS provider, you may or may not need to use a DDNS service like duckdns - I'm using AWS and I have a script that makes sure the DNS A record pointing to my subdomain is up to date twice a day, so I haven't needed to use a DDNS service.

Hope this helps.
 

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
Thanks Samuel! I've actually been running into a wall, so your detailed guide is very valuable to me at this time! I'll give it a go and hope I don't run into too much trouble. I'm not too experienced so initially the length of the guide was very intimidating - but I do want to learn, as well.
 

samuel-emrys

Contributor
Joined
Dec 14, 2018
Messages
136
Thanks Samuel! I've actually been running into a wall, so your detailed guide is very valuable to me at this time! I'll give it a go and hope I don't run into too much trouble. I'm not too experienced so initially the length of the guide was very intimidating - but I do want to learn, as well.
That's the reason it's long - because I've tried to explain as much as I can :)
 

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
That's the reason it's long - because I've tried to explain as much as I can :)
Hm.

When I test my php.ini configuration (jail_ip/info.php) that page shows fine but if I go to just the jail IP it shows me "File not found."

I went on to configure nextcloud it anyway. When I test my configuration, I'm getting an error. (attached)

How do I "reinstall" nextcloud? Where do I get the "CAN_INSTALL" file, and likely other files that may be missing? I've been doing a clean install..

*edit
Oh geez, slipped my mind. Make the file, got the UI. Put in all the right info, but getting this:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user 'nextcloud_admin'@'localhost' (using password: YES)

So I tried altering it..
MariaDB [(none)]> ALTER USER 'nextcloud_admin'@'localhost' IDENTIFIED BY 'a-new-password-here';
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation

*edit2
Heh. I quit - I wasted a week on nextcloud setup already, there's just more and more issues to go through and I don't have the mindset and time to figure it all out and become a guru. Maybe FreeNAS can one day support SSL via Plugins, or a reverse proxy jail plugin with the nextcloud plugin working with it. Else, all of this is really not worth the health.
 
Last edited:

garm

Wizard
Joined
Aug 19, 2017
Messages
1,555
Either you set up a wild card domain A record and use your original server as a reverse proxy or point https://Nextcloud.domain.io to your Nextcloud ip
 

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
Either you set up a wild card domain A record and use your original server as a reverse proxy or point https://Nextcloud.domain.io to your Nextcloud IP

How about if on my original server I set an A record for my subdomain to my dynamic IP (which will be updated via cron from my home server), and I run Let's Encrypt on that same original server for my subdomain. What exactly do I need to do on my home server in order for nextcloud to work with my domain?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,458
What exactly do I need to do on my home server in order for nextcloud to work with my domain?
You shouldn't need to do anything other than tell Nextcloud that's its domain name.
 

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
You shouldn't need to do anything other than tell Nextcloud that's its domain name.
How do I tell Nextcloud what it's domain name is?

Is it this editing /usr/local/etc/nginx/nginx.conf and adding
Code:
server {
    listen      443;
    listen [::]:443;
    server_name mysubdomain.mydomain.com;
    return      301 https://$server_name$request_uri;
} 

Something isn't working so I need to know if this is correct since it could be an issue elsewhere..
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,458
I hadn't thought about the web server config, though you'd need to adjust it there too, but in Nextcloud's own config file as a trusted domain--though if you used my script, and you set the FQDN properly at the outset, that would be taken care of already.
 

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
I hadn't thought about the web server config, though you'd need to adjust it there too, but in Nextcloud's own config file as a trusted domain--though if you used my script, and you set the FQDN properly at the outset, that would be taken care of already.
When I run your script I can't access nextcloud thru jail IP or domain, so I've been having to do everything manually. At this point I have everything working except when I access https://mysubdomain.mydomain.com/ it hangs and times out.

Quick overview:
External webhost's cpanel: Set subdomain.domain.com as A to dynamic IP, ran Lets Encrypt on subdomain too.
Home server: centurylink modem, router attached, to router I'm using FreeNAS and got nextcloud set up. I self-signed a certificate to be able to access nextcloud as https. And to update dynamic IP on my external webhost's cpanel I'm running a cron from freenas tasks daily.

Question:
Is trusted domains the only place I need to add my subdomain.domain.com, or is there anything else I need to update for my subdomain.domain.com to work with nextcloud?
 

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
@danb35 If it helps any, I just tried running your script for about the 30th time under different settings/environments, still can't see any nextcloud at jail IP or subdomain, http nor https. If it helps clue, after your script was run on a clean environment, I can't find any nextcloud.conf or nginx.conf *anywhere*. Not advanced enough to understand if they're necessary to a SSL setup but I was under impression that they were.

Any idea why I'd be seeing "404 not found" or "Unable to connect"?? I've tried so much it's ridiculous..
 

samuel-emrys

Contributor
Joined
Dec 14, 2018
Messages
136
@danb35 If it helps any, I just tried running your script for about the 30th time under different settings/environments, still can't see any nextcloud at jail IP or subdomain, http nor https. If it helps clue, after your script was run on a clean environment, I can't find any nextcloud.conf or nginx.conf *anywhere*. Not advanced enough to understand if they're necessary to a SSL setup but I was under impression that they were.

Any idea why I'd be seeing "404 not found" or "Unable to connect"?? I've tried so much it's ridiculous..
If you're going to do it all manually, I'd really suggest just going through my guide step by step... it walks through all of the things you need to set. It's worked for hundreds of people without many issues.

This thread feels like it's going around in circles a bit, how about you start by telling us what exact configuration you want. From what you've said so far:

- You have http://www.yourdomain.com hosted by some cloud provider
- You want http://nextcloud.yourdomain.com to be hosted by your personal cloud server
- You want to use duckDNS to act as DDNS for your personal cloud server

What's not clear to me:
- Are you using a reverse proxy or just hosting nextcloud in its own jail?
- Are you trying to resolve the domain name locally?
- Have you created an A record for http://nextcloud.yourdomain.com anywhere?
- What port forwarding rules have you put in place?
- What host override/DNS Resolver settings have you put in place on your router?

FWIW I cover basically this exact situation in my guides, as it's pretty close to what I have set up for myself right now. I really encourage you to just read them and go from there.
 

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
I thought I was very clear, my mistake.
I'm using a standard reseller webhost service (not my server) where I already use mydomain.com. There, I set up a subdomain.mydomain.com, ran Lets Enrypt on it, and set an A record that points to my home dynamic IP.
Now at home, in FreeNAS, I am running a daily cron task that updates my cpanel's A record with my dynamic IP. This part works fine.

The problem I keep running into is not in setting up nextcloud initially. Even FreeNAS's NextCloud v17 Plugin works fine and I can make changes to it following guides, until I try to set it up to work with a domain. I cannot access nextcloud via Jail IP OR subdomain.domain.com. (http nor https)

I've been trying to figure out your guide in what I should be doing and what I should be skipping as it is quite outdated. I'm running into additional issues along the way because of it, to then stumble into something I should've skipped or that I mess up and have to scroll all the way back up and go yet again. I can use dan's script to do it all for me which is great, but, again, I end up with a "successfully installed" nextcloud that I can't see at all via jail IP nor domain - that's ultimately the issue. I'm not doing anything special in my instalation or set up.. I even keep wiping everything back for the 30+ times I've attempted to install nextcloud. If it sounds like I'm losing my mind - I really am. I even put DD-WRT on my router, used a different router, switched computers - the issue is consistent and it's blowing my mind how it seems no one else is running their head into this wall or how you and the guys who very well understand how all this works don't have any ideas other than what you've already done before to have it work then.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,458
I can't find any nextcloud.conf or nginx.conf *anywhere*.
Of course there's no nginx.conf; my script doesn't use nginx as the web server (it uses Caddy instead, and its configuration file is found at /usr/local/www/Caddyfile). There's also no nextcloud.conf; Nextcloud's config file is called config.php, and it's located at /usr/local/www/nextcloud/config/config.php. Everything is configured for HTTPS automatically; there's nothing for you to change in either of those unless you installed the script with a self-signed cert and now want to use a different cert.
Any idea why I'd be seeing "404 not found"
Probably because you're trying to reach your nextcloud installation by its IP address rather than by its hostname. This isn't supported.
or "Unable to connect"?
Hundreds of possibilities, but my first guess would be a combination of DNS and NAT issues. Your router should be set up to return the local IP address of your Nextcloud jail for nextcloud.yourdomain.com. That means that when you ping nextcloud.yourdomain.com from a computer on your LAN, it should be pinging the local IP address of your jail. DD-WRT supports this, from what I can see on Google (it's been many years since I used dd-wrt, so I won't be able to help you with any details here; I use pfSense instead). If that's working, you should be able to reach your installation from your LAN at https://nextcloud.yourdomain.com. If you're getting an "unable to correct" at that point, Caddy's probably failed to start, and you'll need to investigate why in /var/log/caddy.log.

The next likely issue is port forwarding. If you want your installation to be accessible from the outside world, you need to have ports 80 and 443 forwarded to that jail, and your ISP needs to not block either of those ports--the latter is a common problem with residential ISPs.
 
Last edited:

samuel-emrys

Contributor
Joined
Dec 14, 2018
Messages
136
I thought I was very clear, my mistake.
I'm using a standard reseller webhost service (not my server) where I already use mydomain.com. There, I set up a subdomain.mydomain.com, ran Lets Enrypt on it, and set an A record that points to my home dynamic IP.
Now at home, in FreeNAS, I am running a daily cron task that updates my cpanel's A record with my dynamic IP. This part works fine.

The problem I keep running into is not in setting up nextcloud initially. Even FreeNAS's NextCloud v17 Plugin works fine and I can make changes to it following guides, until I try to set it up to work with a domain. I cannot access nextcloud via Jail IP OR subdomain.domain.com. (http nor https)

I've been trying to figure out your guide in what I should be doing and what I should be skipping as it is quite outdated. I'm running into additional issues along the way because of it, to then stumble into something I should've skipped or that I mess up and have to scroll all the way back up and go yet again. I can use dan's script to do it all for me which is great, but, again, I end up with a "successfully installed" nextcloud that I can't see at all via jail IP nor domain - that's ultimately the issue. I'm not doing anything special in my instalation or set up.. I even keep wiping everything back for the 30+ times I've attempted to install nextcloud. If it sounds like I'm losing my mind - I really am. I even put DD-WRT on my router, used a different router, switched computers - the issue is consistent and it's blowing my mind how it seems no one else is running their head into this wall or how you and the guys who very well understand how all this works don't have any ideas other than what you've already done before to have it work then.
Literally, just follow it all. Even though it was written for NC 15, it still works. Given that you didn't answer any questions about your router configuration, I'm assuming you don't know. This is where your issue probably is - the traffic going to your home server probably isn't being properly forwarded to your nextcloud instance. Also, if you obtained LetsEncrypt in the same location as your A record; this is the wrong place to run LetsEncrypt. The certificate will need to be installed wherever your Nextcloud web server is (or reverse proxy; you didn't answer that either).

If you want to provide some details about your firewall configuration, that would probably help diagnose the issue.
 

profzelonka

Explorer
Joined
Mar 29, 2020
Messages
67
Thank you @danb35 @samuel-emrys

The issue was that my ISP was blocking port 443, and I also hadn't realized my modem had DHCP on. I called my ISP, and changed my modem's WAN to Transparent Bridge and set up PPPoE on my router. Now everything I'm doing is working perfectly fine. I really appreciate it, and apologize for being difficult, the thing took the best of me I feel. Thank you.
 
Top