AngularJS and API Backend via nginx proxy – Sample nginx virtual host

If you want to run your AngularJS front-end web application and run nginx as your API proxy server, then the following nginx virtual host configuration can help you.

#AngularJS frontend with proxied API backend
server {
        listen 80;
        server_name your-angularjs-public.url;

        root your/angularjs/app/root-directory;
        index index.html;

        location / {
                # If you want to enable html5Mode(true) in your angularjs app for pretty URL
                # then all request for your angularJS app will be through index.html
                try_files $uri /index.html;

        # /api will server your proxied API that is running on same machine different port
        # or another machine. So you can protect your API endpoint not get hit by public directly
        location /api {
                proxy_pass http://api-server-url;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        #Static File Caching. All static files with the following extension will be cached for 1 day
        location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
                expires 1d;

This will help you lot to configure your Nginx proxy for your API backend and run your API with AngularJS based web application interface.

Start forever node command after reboot

Unfortunately by default forever will be terminated in every reboot of your system. So if you want to restart your forever script after every reboot.

Then you can simply handle that with crontab @reboot attribute. Here is the crontab command you need simply.

@reboot /usr/local/bin/forever start yourNodeJSAppStartFile.js

mongodump usage for MongoDB backup and restore

According to MongoDB Backup manual, mongodump is a very handy tools for MongoDB administrator to backup and restore full mongodb cluster or single database or single collection.

mongodump usage

Here is a very simple command to take backup or restore mongodb system.


sudo mongodump --host hostName -d databaseName --port portNumber --username userName --password passWord --out directoryLocation

with the above command you can take backup of your database. I don’t need to explain all parameters as I wrote variable name very clearly.


 sudo mongorestore --host hostName -d databaseName --port portNumber --username userName --password passWord backupSourceLocation 

I guess it will help you quickly.

MikroTik Simple queue script – add all IP

To add all IPs in your MikroTik Simple queue, just open your MikroTik RouterOS terminal and run the following script.

:for x from 1 to 254 do={/queue simple add name="queue-$x" max-limit=2M/2M target="192.168.1.$x"}

Here in max-limit variable you can define max speed upload/download. For example I used 2M for both download and upload. This simple loop script will easily add all of your IPs in your MikroTik Simple Queue. After that you can manually modify when you need for any specific IP.

Find all IP address with subnets of a specific organization

Let’s assume you want to find all IP address of Facebook with all of their subnets. Let’s see how you can get it easily. In you Linux machine install ‘whois’ package first with the following command:

sudo apt-get install whois

After installing, you can just find lots of network identification information for a specific company with it’s any IP address, AS (Autonomous System) Numbers.

In your terminal just type the following command with AS23956 number (Facebook’s AS number)

whois -h '!gAS23956'

(Note: AS23956 is the AS number of Facebook)

You will get all the IP lists with it’s subnets in a result something look like: ....

So if you know the AS number of any organization then you can be able to figure out all of it’s owned IP addresses with Subnet. Now let’s see how you can find the AS number of any organization.

whois -h

descr: Route object of Grameen Phone
origin: AS24389
changed: 20080731
source: APNIC

From the above output you can see the value of AS of GrameenPhone. That is AS24389. Now to see all the IP list with subnetting for this AS use the following command that I described above already.

whois -h '!gAS24389'

(Note: Any organization can have multiple AS number).