If you want to host your own website using raspberry pi, one way is to run an apache server, then use ngrok's dns service to give it a name instead of typing in the ip address which will limit the access to only local networks. **nginx** sudo apt install nginx After installing nginx, I will tell you the procedure to host your local site using the nginx domain name. sudo mkdir /var/www/mysite Place your files in this directory treating it as the root for your site. I cloned my github pages site and will also add a step to auto update it whenever my github pages site gets updated. cd /var/www/mysite/ sudo git clone Create a conf file for your site at /etc/nginx/sites-available/ sudo nano /etc/nginx/sites-available/mysite.conf Contents are: server { listen 80; listen [::]:80; server_name your-domain-name.ngrok-free.app; root /var/www/; index index.html index.htm index.nginx-debian.html; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } } We need to create a symlink or shortcut of this conf file in sites-enabled. sudo ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/mysite.conf sudo nginx -t (This test command should pass before going any further) ## I encountered two errors here, one is if the domain name is too long, go to /etc/nginx/nginx.conf. You should uncomment a line that should say "server_name_has_bucket_size 64;". Increase to 128 and so on if it's still big. The other error is more common, a busy port 80 due to running apache. To check what is using port 80, use `sudo netstat -plant | grep 80`. If you can see something running on port 80, run this: sudo /etc/init.d/apache2 stop ## Finally, restart the nginx server sudo /etc/init.d/nginx restart After setting up the site, you might want to auto-update the github repository if any changes are made. So, lets automate the git pull. Create a file, maybe gitpull.sh in tools/nginx sudo mkdir tools/nginx sudo nano tools/nginx/gitpull.sh The contents of this file are (The below part reset --hard will remove any uncommitted changes): cd /var/www/gitpages && sudo git fetch --all && sudo git reset --hard origin/main && sudo git pull origin main sudo chmod +x nginx/gitpull.sh Now, we should add this file gitpull.sh to crontab so that it can run automatically. crontab -e */1 * * * * /home//tools/nginx/gitpull.sh The above command will check every minute for changes and pull any new file changes. In the five places, 1st one is for minutes, 2nd one is for hours, and so on. So if you want it to run every 12 hours, change it like this: 0 */12 * * * /home//tools/nginx/gitpull.sh **ngrok** ->To download ngrok: curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok ->Sign up to ngrok, you will get an authentication token. You should add it to the config file. ngrok config add-authtoken ->A test tunnel can be started using: ngrok http 80 ->To get a domain for the pi's ip, go to ngrok.com and login. There you can see domains in Cloud Edge. There create a new domain. To start the tunnel using the domain: ngrok http --domain=some-website-name.ngrok-free.app 80 To share the files in a location: ngrok http --domain=some-website-name.ngrok-free.app /media//share/ Now you can access the website from networks out of your local network by searching for the in your browser. ->You can also set up a domain name kind of thing to your device ip, that can be done by adding this to your config. ngrok config edit The contents should be: version: "2" authtoken: your_token tunnels: vnc: proto: tcp addr: 22 ssh: proto: tcp addr: 5900 site: proto: http addr: 80 domain: some-website-name.ngrok-free.app ->To check configuration file, use "ngrok config check" Note: you can start these tunnels manually by running the below commands - ngrok start --all or ngrok start --config=/home//.config/ngrok/ngrok.yml --all To create a service: sudo nano /etc/systemd/system/ngrok.service Contents inside are: [Unit] Description=ngrok After=network.target [Service] ExecStart=/usr/local/bin/ngrok start --config=/home//.config/ngrok/ngrok.yml --all [Install] WantedBy=multi-user.target sudo systemctl daemon-reload && sudo systemctl enable ngrok && sudo systemctl start ngrok && sudo systemctl status ngrok If you want to run multiple services on different ports of the same domain, it can't be done using ngrok. As an alternative, I created another ngrok account using +something trick of gmail, and got a new domain name. Now lets create a new yml file and service for it. mkdir .config/ngrok2 && sudo nano .config/ngrok2/ngrok2.yml The contents should be: version: "2" authtoken: tunnels: cloud: addr: 8080 proto: http domain: second-domain-name.ngrok-free.app Test if it is working by using ngrok start command. If it runs without errors, all is well. ngrok start --config=/home//.config/ngrok2/ngrok2.yml --all Now create a seperate service for it, by copying the ngrok.service file. sudo cp /etc/systemd/system/ngrok.service /etc/systemd/system/ngrok2.service sudo nano /etc/systemd/system/ngrok2.service Change the path from "--config=/home//.config/ngrok/ngrok.yml" to "--config=/home//.config/ngrok2/ngrok2.yml" in ExecStart. sudo systemctl daemon-reload && sudo systemctl enable ngrok2 && sudo systemctl start ngrok2 && sudo systemctl status ngrok2 This should start both the services running on two different ports at two different domains. For more info on this, refer: https://stackoverflow.com/questions/25522360/ngrok-configure-multiple-port-in-same-domain