skip to Main Content

I’m trying to point my squarespace domain I purchased to my Public IP.

I am using Ubuntu Server

I have a localhost Next.js app on port 3000. I port forwarded that port and I can access it on a different computer/different network via using my public IP.

Do I need to change my /etc/hosts file to involve the domain name in it attached to my public IP/ipv4

I’m brand new on using domains and networking so your patience is appreciated.

Any advice or points in the right direction would be appreciated.

I pointed to my domain to my public IP via DNS A with @ in the host field.

I’d imagine if I do www.example.com:3000 it’d come to my webserver but it doesn’t.

I thought about trying to set up express.js on my next.js app but not entirely sure if id benefit.

2

Answers


  1. I assume you are pointing it to your home network? Keep in mind that you IP address might change from time to time.

    Furthermore you can check how your DNS records are currently set as it can take up to 24 hours for them to update when you make changes. https://who.is/

    You should also make sure your next app listens to 0.0.0.0 and not localhost.

    If you only need it for testing purposes you can also use ngrok

    Login or Signup to reply.
  2. Let’s say your domain is example.com and your IP is 123.12.34.56, you need to set A record of example.com to 123.12.34.56. Then you need to set up example.com on your server. Following is an example configuration apache webserver.

    <VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
    
        ProxyRequests Off
        ProxyPreserveHost On
    
        <Proxy *>
            Order deny, allow
            Allow from all
        </Proxy>
    
        ProxyPass / http://localhost:3000/
        ProxyPassReverse / http://localhost:3000/
    </VirtualHost>
    

    Once this setup is completed, you can access your web service without a port number.

    But if you want to access your web service without the help of a web server, then you need to allow port number 3000 through the firewall.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search