Answer for KodeKloud Question -Setup SSL for Nginx

 The system admins team of xFusionCorp Industries needs to deploy a new application on App Server 3 in Stratos Datacenter. They have some pre-requites to get ready that server for application deployment. Prepare the server as per requirements shared below:

1. Install and configure nginx on App Server 3.
2. On App Server 3 there is a self signed SSL certificate and key present at location /tmp/nautilus.crt and /tmp/nautilus.key. Move them to some appropriate location and deploy the same in Nginx.
3. Create an index.html file with content Welcome! under Nginx document root.
4. For final testing try to access the App Server 3 link (either hostname or IP) from jump host using curl command. For example curl -Ik https://<app-server-ip>/.

Sample Answer:

# read the question and find that, on which server nginx needs to be install ( in my case its on app 3 )


#login to app 3 server

    ssh <user>@<server IP>

#switch to root user 

    sudo su 

#install the nginx( epel-release also need to be install before nginx)

    yum install -y epel-release

    yum install -y nginx 

 #edit the nginx conf file 

    cd /etc/nginx 

    vi nginx.conf


# you need do the changes on 2 section as below ( the IP should be the respective app server IP)



# under the settings for TLS enabled server section you need to uncomment by removing the # in front of all the lines up to the bottom of the page and edit as below entries only.



# double check that, your nginx.conf file looks like as per the above screenshots
    save the file 

# now let's copy the nautilus.crt and nautilus.key files to the correct location

        cp /tmp/nautilus.crt /etc/pki/CA/certs/

        cp /tmp/nautilus.key /etc/pki/CA/private/

# now create an index.html with word Welcome! on nginx document root ( in the above screenshot you can find the root location )

  cd /usr/share/nginx/html

    ls -l

#when you do ls -l command you might be index.html already presented on this location but you can't edit that file.

    vi index.html ( you will get error when you tried to save the file>

# 2 solution for the above issue 

     # you can remove the existing file and create a new one 

                rm -r index.html and recreate it  vi index.html with a word Welcome!

    # you can do as below 

            mkdir /usr/share/nginx/doc/HTML

            # navigate to newly creted location

                cd /usr/share/nginx/doc/HTML

            # create inside HTML directory

                   vi index.html with a word Welcome!

            #save the file 

                    wq!

# start the nginx service 

        systemctl start nginx

# verify from JUMP host( you wil get 200 Ok response)

        curl -Ik https://<app-server-ip>/ 

*  if you face any issues in the steps, please comment me under this post.

Note: **The Question copied it for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.


1 comment:

Featured Post

Answer for Kodekloud DEVOPS Questions - Init container in Kubernetes

Question: 1. Create a Deployment named as ic-deploy-devops. 2. Configure spec as replicas should be 1 , labels app should be ic-devops , ...