Adding an existing project to GitHub using the command line

Putting your existing work on GitHub can let you share and collaborate in lots of great ways.

If you are migrating your project from CodePlex, read the migration guide for more information.

  1. Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.
  2. Open Terminal.
  3. Change the current working directory to your local project.
  4. Initialize the local directory as a Git repository.
    git init
  5. Add the files in your new local repository. This stages them for the first commit.
    git add .
    # Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
  6. Commit the files that you’ve staged in your local repository.
    git commit -m "First commit"
    # Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
  7. Copy remote repository URL fieldAt the top of your GitHub repository’s Quick Setup page, click  to copy the remote repository URL.
  8. In Terminal, add the URL for the remote repository where your local repository will be pushed.
    git remote add origin remote repository URL
    # Sets the new remote
    git remote -v
    # Verifies the new remote URL
  9. Push the changes in your local repository to GitHub.
    git push origin master
    # Pushes the changes in your local repository up to the remote repository you specified as the origin



How to create add Subdomain in GoDaddy and Azure

How to create add Subdomain in GoDaddy and Azure

1. Login in to GoDaddy and create a CNAME record,
HOST – should be your subdomain.
POINTS TO – should be your azure link, which is generated by azure for the web applications.

2. Login in to Azure and click the particular web applicaion and click “Custom Domains”

and click the “Add HostName” Button

3. Enter your subdomain name with main domain name.
Subdomain – freshworks
Maindomain –, which is bought from GoDaddy and under this main domain, we add many subdomain.

4. Click the “Validate” button, Once you clicked after some time Host/Domain availability should be green tick mark.

5. Click the “Add Host Name” button and it will automatically add to your subdomain

Security Testing for Web Applications

Security Testing:-


Cross-Site Request Forgery (CSRF) is an attack that forces an end user to execute unwanted actions on a web application in which they’re currently authenticated. CSRF attacks specifically target state-changing requests, not theft of data, since the attacker has no way to see the response to the forged request

1. Preventing CSRF requires three things:

1.1 Make sure your forms use POST(Already done)

1.2 Make sure your site is not vulnerable to XSS(Need to do)

1.3 Make your forms use a CSRF key(Already done)

I agree with the other two; this could be done on the browser-side, but would make impossible to perform authorized cross-site requests. Anyways, a CSRF protection layer could be added quite easily on the application side (and, maybe, even on the webserver-side, in order to avoid making changes to pre-existing applications) using something like this:

A cookie is set to a random value, known only by server (and, of course, the client receiving it, but not a 3rd party server)

Each POST form must contain a hidden field whose value must be the same of the cookie. If not, form submission must be prevented and a 403 page returned to the user.

CSRF, or Cross-Site Request Forgery, is a vulnerability very common in websites. In short, it means that if you have your site at, and an attacker at can display a form similar to one of your site’s, and make users on his site submit the forms on your site, possibly without their knowledge.

For example, if your blog comment box allows users to write JavaScript snippets that aren’t escaped in any way by the server and are ran, it’s most likely vulnerable to an XSS attack.


Convert special characters to HTML entities


The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe> or <object> . Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.

clickjacking attack:-

In some websites, we see some adds in iframe right.

An attacker can make use of iframe to trick the user to get into some malicious page.

design of the iframe may look genuine but he would be tricking the user to go into a malicious page or a site.

To check this issue


There are three possible directives for X-Frame-Options:-

X-Frame-Options: DENY

X-Frame-Options: SAMEORIGIN

X-Frame-Options: ALLOW-FROM

Content Security Policy:-

Is an W3C specification offering the possbility to instruct the client browser from which location and/or which type of resources are allowed to be loaded. To define a loading behavior, the CSP specification use “directive” where a directive defines a loading behavior for a target resource type.

Directives can be specified using HTTP response header (a server may send more than one CSP HTTP header field with a given resource representation and a server may send different CSP header field values with different representations of the same resource or with different resources) or HTML Meta tag, the HTTP headers below are defined by the specs:

  • Content-Security-Policy : Defined by W3C Specs as standard header, used by Chrome version 25 and later, Firefox version 23 and later, Opera version 19 and later.
  • X-Content-Security-Policy : Used by Firefox until version 23, and Internet Explorer version 10 (which partially implements Content Security Policy).
  • X-WebKit-CSP : Used by Chrome until version 25

More Details:-


Configure your web server to include an X-Frame-Options header. Consult Web references for more information about the possible values for this header:-

Note:- (Use case #3: SSL only)

/etc/nginx/sites-available/default:- Only Specified Domain and Sub Domain Restriction

server {

listen 80;

listen [::]:80;

#add_header Content-Security-Policy “default-src ‘self’; ‘’; ‘*’ ;”;

add_header Content-Security-Policy “default-src http:; script-src http: ‘unsafe-inline’; style-src http: ‘unsafe-inline'”;

add_header X-Content-Security-Policy “default-src http:; script-src http: ‘unsafe-inline’; style-src http: ‘unsafe-inline'”;

add_header X-WebKit-CSP “default-src http:; script-src http: ‘unsafe-inline’; style-src http: ‘unsafe-inline'”;


Only Specified Url Restriction:- sudo vim /etc/nginx/sites-available/default

server {

listen 80;

listen [::]:80;

#add_header Content-Security-Policy “default-src ‘self’; ‘’; ‘*’ ;”;

add_header Content-Security-Policy “connect-src http://*;;

add_header X-Content-Security-Policy “connect-src http://*;;

add_header X-WebKit-CSP “connect-src http://*;;

add_header X-XSS-Protection “1; mode=block”;

Apply the following changes to the web.config file to prevent ASP.NET version disclosure:-


Install thenginx-extraspackages like this:

install nginx-extras


http {


# Basic Settings


sendfile on;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 65;

types_hash_max_size 2048;

server_tokens off;


more_clear_headers “Content-Type: “;

more_clear_headers “Accept-Ranges: “;

more_clear_headers “Content-Length: “;

more_clear_headers “server”;

more_clear_headers “ETag”;

more_clear_headers “Date”

more_clear_headers “Last-Modified”;

more_clear_headers “Connection”;

It’s recommended to disable OPTIONS Method on the web server:-


Web Application Security

Default nginx configuration is not perfect and can have many vulnerabilities that’s why we harden them to make it secure.

Disable unwanted HTTP methods

Most of the time, you need just GET, HEAD & POST HTTP request in your web application. Allowing TRACE or DELETE is risky as it can allow Cross-Site Tracking attack and potentially allow hacker to steal the cookie information.

  • Modify default.conf and add following under server block


if ($request_method !~ ^(GET|HEAD|POST)$ )
return 405;

Remove or restrict access to all configuration files acessible from internet:-

sudo chmod 400 Gruntfile.js

Restrict access to this directory or remove it from the website:-

drwxrwxr-x 4 freshgrcdomainfront freshgrcdomainfront 4096 Aug 9 10:52 src

sudo chmod 445 src/

dr-x—— 4 freshgrcdomainfront freshgrcdomainfront 4096 Aug 9 10:52 src

Investigate if it’s possible to reduce the response time for this page:-

GET /src/bower_components/angular-material/angular-material.js

How to deploy angular application in azure virtual machine

How to deploy angular application in azure virtual machine



Virtual Machine Configuration:-

SSL using Let’s Encrypt:-

How to install Nginx:-

Installing the all updates in ubuntu debian version

sudo apt-get update

Installing the Nginx web server, please follow the below command

$ sudo apt-get install nginx

Adjust the Firewall

We can list the applications configurations that 
ufw knows how to work with by typing:

$ sudo ufw app list

Firewall should be enable,

$ sudo ufw status (sudo ufw enable/disable)

How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04

Set Up New Document Root Directories

$ sudo mkdir -p /var/www/

We can use the $USER
environmental variable to assign ownership to the account that we are currently signed in on (make sure you’re not logged in as root). This will allow us to easily create or edit the content in this directory:

$ sudo chown -R $USER:$USER /var/www/

The permissions of our web roots should be correct already if you have not modified your umask
value, but we can make sure by typing:

sudo chmod -R 755 /var/www

Create Sample Pages for Each Site

Now that we have our directory structure set up, let’s create a default page for each of our sites so that we will have something to display.

Create an index.html
file in your first domain:

$ nano /var/www/


    <head>         <title>Welcome to!</title>     </head>     <body>         <h1>Success!  The server block is working!</h1>     </body> </html>

Save and close the file when you are finished.

Create the First Server Block File

As mentioned above, we will create our first server block config file by copying over the default file:
$ sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/

Now, open the new file you created in your text editor with sudo privileges:
sudo nano /etc/nginx/sites-available/
Change the below,

80 default_server;

        listen [::]:80 default_server;



        listen [::]:80;

and also set the root element,


and set the server name too,

Enable your Server Blocks and Restart Nginx

Now that we have our server block files, we need to enable them. We can do this by creating symbolic links from these files to the sites-enabled directory, which Nginx reads from during startup.

We can create these links by typing:

$ sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
These files are now in the enabled directory. We now have three server blocks enabled, which are configured to respond based on their listen
directive and the server_name
(you can read more about how Nginx processes these directives here):

  • Will respond to requests for
  • Will respond to requests for
  • default: Will respond to any requests on port 80 that do not match the other two blocks.

$ sudo nano /etc/nginx/nginx.conf
Within the file, find the server_names_hash_bucket_size
directive. Remove the #
symbol to uncomment the line:


    . . .     server_names_hash_bucket_size 64;     . . . }

Next, test to make sure that there are no syntax errors in any of your Nginx files:

$ sudo nginx -t

If no problems were found, restart Nginx to enable your changes:

$ sudo systemctl restart nginx

Test your Results
Now that you are all set up, you should test that your server blocks are functioning correctly. You can do that by visiting the domains in your web browser:

You should see a page that looks like this:

How To Secure Nginx with Let’s Encrypt on Ubuntu 16.04

Installing Certbot

The first step to using Let’s Encrypt to obtain an SSL certificate is to install the certbot
software on your server. The Certbot developers maintain their own Ubuntu software repository with up-to-date versions of the software. Because Certbot is in such active development it’s worth using this repository to install a newer Certbot than provided by Ubuntu.

First, add the repository:

$ sudo add-apt-repository ppa:certbot/certbot

You’ll need to press ENTER
to accept. Afterwards, update the package list to pick up the new repository’s package information:
$ sudo apt-get update
And finally, install Certbot with apt-get:
$ sudo apt-get install python-certbot-nginx

Updating the Firewall

If you have the ufw
firewall enabled, as recommended by the prerequisite guides, you’ll need to adjust the settings to allow for HTTPS traffic. Luckily, Nginx registers a few profiles with ufw
upon installation.

You can see the current setting by typing:

$ sudo ufw status

To additionally let in HTTPS traffic, we can allow the “Nginx Full” profile and then delete the redundant “Nginx HTTP” profile allowance:

$ sudo ufw allow ‘Nginx Full’

$ sudo ufw delete allow ‘Nginx HTTP’

Your status should look like this now:

sudo ufw status (Status should be active)

Obtaining an SSL Certificate

Certbot provides a variety of ways to obtain SSL certificates, through various plugins. The Nginx plugin will take care of reconfiguring Nginx and reloading the config whenever necessary:
$ sudo certbot –nginx -d -d

If you have no errors, reload Nginx:
$ sudo systemctl reload nginx

Setting Up Auto Renewal

$ sudo crontab -e

3 * * * /usr/bin/certbot renew --quiet

The 15
3 * * *

part of this line means “run the following command at 3:15 am, every day”. You may choose any time.

The renew
command for Certbot will check all certificates installed on the system and update any that are set to expire in less than thirty days. --quiet
tells Certbot not to output information or wait for user input.

will now run this command daily. All installed certificates will be automatically renewed and reloaded when they have thirty days or less before they expire.


How to launch a sub domain with Let’s Encrypt SSL in AngularJs/GoDaddy:-

How to launch a sub domain in AngularJs/GoDaddy:-

1. First you have add sudomain ownership in GoDaddy,

Add a ‘A’ record in GoDaddy with Host as ‘*’,

2. Next you need to change the starting page of AngularJs in app.config.js

Whatever mention in “.otherwise(‘/domainname’);”, this should starting page of AngularJs.
3. Next need to change to domainCtrl.js file,

window.location= “http://”+vm.company_name+&#8221;.localhost:4000/#!/login”;

4. In SessionController.rb need to change the following code,

def login

@user = Authenticator.user?(params[:email], params[:password])

if @user

if @user.company_admin.nil?

subdomain =


subdomain =


subdomain = ”

subdomain = @user.get_company.sub_domain if @user

val = request.headers[‘HTTP_REFERER’]

sub_domain = ”

unless val.index(“.”).nil?

start_index = val.index(“//”)+2

end_index = val.index(“.”)-1

sub_domain = val[start_index..end_index]


if @user && subdomain == sub_domain



render json: { message: ‘Invalid email/password/sub_domain’, status: 401 }, status: 401


=begin if @user



render json: { message: ‘Invalid email/password/sub_domain’, status: 401 }, status: 401




render json: { message: ‘Invalid email/password/sub_domain’, status: 401 }, status: 401



5. How to add let’s encrypt certicate with subdomain also,