Search code examples
nginxproxypass

nginx subdomain proxy pass not working


I am trying to redirect a subdomain on my website. For now, I have added the following block to the file at /etc/nginx/nginx.conf

    server {
        listen 80;
        server_name notebook.mysite.com;

        location / {
            proxy_pass http://0.0.0.0;
        }
    }

This should make visiting notebook.mysite.com the same as visiting mysite.com and show the homepage. Eventually, I will add a port so the location block contains proxy_pass http://0.0.0.0:12345; However, when I visit http://notebook.mysite.com my browser gives me the error

This site can’t be reached

notebook.mysite.com’s server DNS address could not be found.
DNS_PROBE_FINISHED_NXDOMAIN

Anybody know why this is, or at the very least how I would go about troubleshooting it?


Solution

  • Turns out I needed to add an A record with my host, Digital Ocean, for this to work properly. I added an A record with a * to redirect all subdomains to my server.