No way to forward ports

Hey I want to use nextcloud from anywhere but I have no way to forward the ports. I have already done some research and came across the possibility of redirecting everything via a VPS. However, I don’t know how to do it. Can someone help me?

I think this is helpfull for you.

Please post more details. Is your nextcloud in your LAN ? If yes you must use e.g. DynDNS and forward 80/443 throw your router to your nextcloud with the DynDNS address .

Post more details.

First, thanks for the quick response. Here are a few more details. Nextcloud runs on a Raspberry pi 4 4GB. It is connected via LAN. I’m going to try the method with AutoSSH. And I have no option to forward ports. Because the router is not mine.

Ok i also think it helps. Perhaps it would be better to host the nextcloud direct on the VPS. You can then include private data also with SSH Remote Port Forwarding and with sftp over the app “external storage support”. On the VPS you then only need the remote-ssh-port listen on localhost (e. g. localhost.2222) and not global ( or

Just looked again and the approach sounds good. can you tell me more about it?

You can install nextcloud on your VPS and use some space of the VPS for your normal nextcloud data (/var/www/html/nextcloud/data) and MariaDB for your users, shares, …

Then you create a Remote-Port-Forwarding from your linux-client in the intranet with:

ssh -R 2222:localhost:22 user-vps@vps-in-the-internet

You can use a restricted user and use a ssh-key to not need a user/pass for access.
Also you can restrict the ssh-key or give the user only the /bin/false.
You must activate port-forwarding on the VPS in /etc/ssh/sshd_config.
For /bin/false you must use option “-N”
ssh -N -R 2222:localhost:22 user-vps@vps-in-the-internet

You also must activate sftp-subsystem on you linux-client in the intranet in /etc/ssh/sshd_config. Then you can test from the VPS:

sftp user-intranet@localhost -p 2222
Use also ssh-keys in this direction to not use user/pass.

Now hopefully you can use “sftp” in the nextcloud app “external storage support” on your VPS.


Without any installation:
You can test the “sftp” acually on your intranet-nextcloud with sftp on the same host (localhost:22). Try this first.

Thanks for the fast respond. I’m unfortunately a beginner and I don’t understand a few things.

  • So I install nextcloud on my VPS

  • then I enter on my linux client (Raspberry pi with 2 TB HDD) (ssh -R 2222: localhost: 22 user-vps @ vps-in-the-internet -p 2222)

  • then I activate the sftp subsystem on my PI.

  • next I enter on my VPS (sftp user-intranet @ localhost -p 2222)

  • then I can use the sftp app.

Is it correct that way?

Yes. But i think you can change the order. It does no really matter.

Please test it with your actual installation.

Activate sftp-subsystem on a linux client in your local network (e.g. boot a linux live usb or install linux instead of windows :wink: ) and configure in your local nextcloud the sftp-service. If you like it implement it for your VPS. If you do not like it, search for other solutions.

Do you already have got a nextcloud?

OK I’m a little confused. So I have to install nextcloud on my PI and on the VPS?

I have another question. What do you think about Ngrok?

No. Then you must only install on your VPS.

I tested it for you:

ssh -R 2222:localhost:22 userx@vps-server-in-the-internet

in action


Nice. sftp works not only with port 22 but also with 2222. :wink:
The performance is not really good. But i think other solutions are also bad.

all right thank you for your patience. I’ll see if I can do it. I will write how it went and whether there are any problems.

My installation can not load pictures. I think the time is to long.
But i can see the loading on the cpu of my inhouse sftp-server.
I think the problem is my vps nextcloud or the nextcloud software.
What a pity.

Hmm wouldn’t it be easier to install ngrok on the local server?

You can test it. But i think it is a general tunneling problem.
Perhaps it is better to use a http-tunnel and not a ssh-tunnel.

I now tested direct sftp (VPS nextcloud to sftp://localhost) and it works better then the remote-port-forwarding-tunnel with ssh-port-forwarding in it.

I think the ssh-tunnel works fine with small files.
Sometimes i must also reload directorys (they are empty).

ok i have now installed ngrok and it seems to work. I entered ./ngrok http 80. Then I added the IP to the trusted IPs. However, I have an upload of only 1 mb. If I use the local IP it is 8mb. Is this a good solution?