Score:-1

Use cloud server's network to serve local server's content

ug flag

I am trying to build a web application for a local community. I'd like to host a postgres database, a SSR frontend server, a REST backend server. The internet and electricity are pretty cheap here and I have a PC lying around. I have a few hard disks and I can raid them for redundancy. A similar spec AWS machine comes out to 170 USD and I think I can do much cheaper than that. I don't expect the application to scale to any level for the forseeable future (50 concurrent users max, same region). The only problem is that I don't have a static IP. IPv6 routing is not prevalent in my area. I can go for simpler BaaS but I want to learn as well.

I have a server on linode (single shared core, 1 GB RAM) with a static IPv4. How can I host everything on my local machine (maybe multiple KVM machines) and serve everything to people?

I have used this script to setup wireguard servers before. Can I use something like `nginx? Are there alternatives? How will my whole setup look like? If I were to use separate virtual machines for frontend, backend and database, how should I network them?

I understand there are many ways to approach this problem, I'm trying to get a feel of "if I can do it". I'd be happy if I can host my own server.

John Hanley avatar
cn flag
I do something similar using WireGuard to connect my local machine to a cloud VM. Then I use Apache to proxy requests to systems on the other side of the WireGuard network. However, I do not recommend this for a production quality setup. It does work for a low cost solution. You can easily replace Apache with Nginx. To ensure the connection from the cloud VM to the local machine stays up, use some kind of software on the local machine that pings/talks to the cloud VM on a periodic basis like once per minute. When your local IP address changes, WireGuard on the cloud VM will then see the change
berinaniesh avatar
ug flag
Do you recommend using separate VMs for frontend, backend and database? @JohnHanley
in flag
The question is off topic, this site is for business environments. Just a hint, you don't need to rent any server, you only need a dyndns service.
berinaniesh avatar
ug flag
I knew dyndns exists, it has been unreliable for me always. And forwarding specific ports is annoying. I am trying to run a business indeed (maybe a very small one) and I need some help in setting up servers. Isn't that what serverfault is about? Maybe my question is not focused enough. Sorry about that. @GeraldSchneider
John Hanley avatar
cn flag
The answer is "it depends". For small workloads, you can easily fit everything on one system. The best deployment/design depends on usage requirements and reliability goals (and other factors such as security, isolation, build-your-own versus managed services, etc). Note: I prefer WireGuard to a dynamic IP service because the traffic is encrypted and the ISP does not know what services you are self-hosting.
berinaniesh avatar
ug flag
Seems nginx can proxy any type of traffic and not just HTTP. I guess I will setup wireguard on local machine, connect it to the VM's network and try to reverse proxy using nginx. Thanks for the help @JohnHanley
vidarlo avatar
ar flag
It should be noted that running stuff in VM's in the cloud is *not* a good idea. It's inflexible and expensive. Cloud makes sense when you go cloud native, e.g. aws database, aws app hosting, aws load balancer etc. That way you get flexible services with a consistent API at a good price point.
Score:0
cn flag

Ignore the server you have. Useless. Use Cloudflare Tunnel and you are done. A small docker level agent initiates all necessary connections to cloudflare and acts as router.

Another more general setup would be to use the linode server as a router and then establish a vpn from your server to it - I ran a company behind residential internet for ages like that (not the website, but people dialling in), for there was no real way to get anything else at that time... stupid limitation in some areas and countries.

berinaniesh avatar
ug flag
I'll try the cloudflare tunnel, seems they have a free plan. I'm looking more towards the second approach. Seems a bit more independent.
cn flag
It is also more work and requires maintenance of multiple systems. If you want tohave the VPN done easy and transparent, check out ZEROTIER.
Score:0
ug flag

It was possible with wireguard and nginx. Right now, the linode server has an ip address of say, 123.123.123.123 and the linode server has a wireguard ip address of 10.66.66.1. If my local server is connected to the same wiregaurd network, it has an ip of 10.66.66.10. Based on this answer, I created an nginx config

stream {
        upstream ssh1 {
                server 10.66.66.10:22;
        }
        server {
                listen 4575;
                proxy_pass ssh1;
        }
}

Now, if I ssh with ssh [email protected] -p 4575, the ssh connection is proxied by nginx to my local server. I think I can expose whatever service I want this way with nginx.

Ideally, I'd like to have a separate domain for my local server eg. (server1.example.com) and all connections go directly to the local machine. Let me know if that's possible.

Score:-2
si flag

Connect to the cloud server: Using a remote access tool like SSH, connect to the cloud server and configure it to retrieve the content from the local server. You can use a tool like rsync to transfer the content from the local server to the cloud server.

Serve the content: Once the content is transferred to the cloud server, configure it to serve the content to clients. This can be done using a web server like Apache or Nginx, or any other server software that can serve the content.

server's network to serve local server's content, making it accessible to clients from anywhere in the world. However, it's important to ensure that you have proper security measures in place to protect the content and prevent unauthorized access.

cn flag
Not answering the question - if the OP wanted to push the content, he would not ask how to serve it from local.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.