-1

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.

ads
  • 111
  • 2
  • 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. – Michael Hampton Sep 13 '21 at 15:52

1 Answers1

0

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.

boppy
  • 476
  • 2
  • 5