Score:-1

How to make a private home server connected to a wireguard server in cloud vpn accessible to the public?

es flag
ads

Basically what I want to do is make a local home server accessible publicly in the internet. Unfortunately my ISP is using CGNAT and to get a public ip, I need to pay extra (around $50). I figured it's cheaper to use VPS instead.

So I have setup a Wireguard Server in Google Cloud via Compute Engine VM running Ubuntu 20.04. I also setup a Wireguard Client for my local server at home and connected it to the Wirequard server in Google Cloud. Lastly I setup another Wireguard client on my Android phone, connected it to the server and everything is working fine. When I'm on wireguard on my android phone, I can see my local server from the outside (using mobile data for testing purposes).

Now I want to make the local server at home available to the public. I have a domain and setup the necessary records. When I ping it, it returns the public ip of the GCE VM which I believe means its working fine. Next I installed Nginx in my GCE VM. Got this running fine. I was able to access the default Nginx page via the domain and public ip address. I then modified the default config using the following and restarted Nginx after.

server {
    listen 80;
    listen [::]:80;

    server_name sub.domain.org; #sample only

    location / {
            proxy_redirect http://10.200.200.2 http://sub.domain.org;
    }
}

My Wireguard is on the 10.200.200.x ip range (not sure if this is the correct term) and 10.200.200.2 is the wireguard ip address of my local home server.

I may not have understood how Nginx work but I was expecting that thru Nginx, I will be able to access my local home server publicly by browsing http://sub.domain.org. Unfortunately I was not able to access it publicly. It is only accessible when I connect to wireguard.

Is there anything else that I need to do?

Appreciate any feedback.

Michael Hampton avatar
cz flag
Forget the VPN and just host your stuff directly on the Google VM. We do not recommend hosting at home for a variety of reasons, and we certainly do not support it.
Score:0
ru flag

You should read through the docs of ngx_http_proxy_module at http://nginx.org/en/docs/http/ngx_http_proxy_module.html.

Docs for proxy_redirect states:

Sets the text that should be changed in the “Location” and “Refresh” header fields of a proxied server response.

So currently you only advised nginx to change some text in some headers, but not to pass any traffic to the (home server) target.

You need, at least, a proxy_pass directive to make that work.

Keep in mind that nginx does not replace contents of your sites! So if you site on you home server serves absolute paths, you need to fix that.

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.