Extremely Serious

Category: Raspberry Pi

Making your home Nginx on Raspberry Pi accessible from the Internet

Pre-requisites

  • Nginx installed on your Raspberry Pi or you can follow the procedure from here.
  • A router that can forward ports.

Procedure

  1. Access your router firmware and look for port forwarding configuration.
  2. Then configure your router port 80 to be forwarded to your local Raspberry Pi with Nginx with static IP also with port 80 (i.e. where Nginx is listening by default).

Port Forwarding Procedures

Telecom - Technicolor Gateway TG582n

Using NoIP’s Dynamic DNS Update Client (DUC) with Raspberry Pi

Sometimes we wanted our personal service to be hosted in our own network at home and we wanted it to be accessible via internet. However, our ISP doesn't provided us with a static IP. Thus our public IP could be anything for some moment. Knowing this different IP's is not ideal and tedious. This is where a service like NoIP comes in where it gives a more easy to remember hostname that is attached to your current public IP. But keeping it updated is still a tedious thing to do.  This is where we can use Raspberry Pi to do this task for us.

Assumption

  • Windows is being used for configuration.

Pre-requisites

  • Existing NoIP account with registered hostname or sign up here and register a hostname.
  • Existing Raspberry Pi Server or setup a new one.
  • WinSCP is installed (or any SFTP client you know how to use). In the  procedure I am only using WinSCP for simplicity.
  • Putty is installed (or any SSH client you know how to use). In the procedure I am only using Putty for simplicity.

Procedure

  1. Download Dynamic DNS Update Client for Linux here (i.e. normally named noip-duc-linux.tar.gz).
  2. Using WinSCP upload the newly downloaded file to the home directory of the account with sudo group on your target Raspberry Pi. The output is similar to the following when using the default pi user:
  3. Using putty sign-in to your Raspberry Pi using the account you used in the previous step.
  4. In your home directory extract the tarball using the following command:
    tar -zxf noip-duc-linux.tar.gz

    The extract is a directory similar to the following format:

    noip-<version>
  5. Go into the extracted folder and install using the following commands:
    sudo make
    sudo make install
  6. Type in your login or email address (i.e. you used on noip sign up ) and press Enter.
  7. Type in your password (i.e. you used on noip sign up ) and press Enter.
  8. Type in your update interval and press Enter or just press Enter (i.e. if default [30] is good for you).
  9. Press Enter and the output is similar to the following if your noip version is 2.1.9-1:
  10. Go to /etc/init.d directory with the following commad:
    cd /etc/init.d
  11. Create a noip2 file with the following command:
    sudo vi noip2
  12. Type i (i.e. insert mode) and paste the following script:
    #! /bin/sh
    #. /etc/rc.d/init.d/functions   # uncomment/modify for your killproc
    case "$1" in
    start)
    echo "Starting noip2."
    sleep 10
    /usr/local/bin/noip2
    ;;
    stop)
    echo -n "Shutting down noip2."
    killproc -TERM /usr/local/bin/noip2
    ;;
    *)
    echo "Usage: $0 {start|stop}"
    exit 1
    esac
    exit 0
    
  13. Type :wq (i.e. write and quit) and then press enter.
  14. Make the script executable with the following command:
    sudo chmod 755 noip2
  15. Go to /etc/rc3.d directory with the following command:
    cd /etc/rc3.d
  16. Create a symbolic link named S05noip2 pointing to the noip2 script you've created earlier with the following command:
    sudo ln -s ../init.d/noip2 S05noip2

Validation

After completing the procedure above, do the following:

  1. Identify your current public IP here and note it.
  2. Ping the hostname you've registered to NoIP using the command terminal and check if it is equal to the IP you've noted from the previous step.