Point a domain name to Raspberry Pi web server

In case you missed out the previous posts, here they are:

I have explained how to setup a website (wordpress blog) on raspberry pi web server. So far our website is only reachable in local network. Lets assume that have a domain name that you want to point to website so that external users will be able to reach you.

This post explains how to point a domain name to local raspberry pi I.P address. We will also see how to configure a domain name with a raspberry pi web server hosting our website. This is example our web server is nginx.

What we will need

  • Acquire a domain name if you don’t have one already
  • Static external I.P address
  • Point domain name to external I.P address of raspberry pi web server
  • Router access for Port Forwarding on 80
  • Configure web server

Get a domain name – Lets get our hand on a domain name of your choice. There are many providers that offer free domain name. Many others will charge annual fee for the same. Based on your preference and purpose you may go with any provider. In this example, I am using a example domain (www.example.com) bought from a very popular provider – Godaddy.

Static external I.P address – It is easy to know your external I.P address. Just point your browser to service such as http://www.cmyip.com and it will show you your external I.P address. This is the I.P that we will use to point our domain name to. It is important that your ISP/Internet service provider assign you a static I.P address, which is the case with most provider these days. Otherwise you may consider services such as DynDns and No-IP

Point domain to I.P address – The configuration of pointing domain name to I.P address is different from provider to provider but in essence it is very straightforward. For example for Godaddy provider update the A record of domain name to your external I.P address. You can see the Godday guide right here.

Port forwarding – Port forwarding on your router will allow traffic from outside your LAN for redirection to Internal LAN I.P address (and port). In our example we wish to redirect outside traffic on port 80 to our raspberry pi web server ( ). In order to achieve this we will need to open the console/admin on our router configuration. This is different from router to router but pretty much similar for most. If you are unsure Google “<your router model> port forwarding”. There are high chances that you will get specific instruction for your router. To give you a prescriptive here is example screenshot of configuration.

Port Forwarding

Configure Web Server – If you followed here from previous article, then you will need to add server_name directive to determine which server block is used for a given request. SSH into your raspberry pi ( ). Open “default” server block file located at /etc/nginx/sites-available/ in a text editor such as nano

sudo nano /etc/nginx/sites-available/default

Add server_name directive to server block. The updated configuration should look like below

upstream wpapp {         
 server {         
     listen 80; 
     server_name example.com www.example.com;           
     location /  {             
         proxy_pass http://wpapp;         

Save the changes and exit nano editor. Restart the web server

sudo service nginx restart

That’s conclude require changes to point domain name to local rapspberry pi web server. I hope you find it useful. Let me know your feedback below.

2 thoughts on “Point a domain name to Raspberry Pi web server”

Leave a Comment