0% found this document useful (0 votes)
12 views13 pages

Web Service, API and Operating System

The document outlines a series of labs focused on Linux installation, web server configuration, and API concepts. It covers practical tasks such as installing Nginx, Apache, Tomcat, and HAProxy, as well as managing SELinux and memory. Additionally, it explains the differences between SOAP and REST APIs, and provides definitions for key networking terms like DNS, HTTP, and SSL.

Uploaded by

tanvirtechit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views13 pages

Web Service, API and Operating System

The document outlines a series of labs focused on Linux installation, web server configuration, and API concepts. It covers practical tasks such as installing Nginx, Apache, Tomcat, and HAProxy, as well as managing SELinux and memory. Additionally, it explains the differences between SOAP and REST APIs, and provides definitions for key networking terms like DNS, HTTP, and SSL.

Uploaded by

tanvirtechit
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lesson02: Web Service, API and Operating System

LAB: 01- Linux Installation and environment readiness.

Follow the class.

LAB: 02- Selinux & Linux Repository Management.

Linux Repository Management:

# yum install nginx


# cd /etc/[Link].d/
# vim [Link]
[nginx]
name=nginx repo
baseurl=[Link]
gpgcheck=0
enabled=1
:x

# yum clean all


# yum repolist
# yum install nginx
# systemctl status nginx
# systemctl start nginx
# systemctl status nginx
# systemctl is-enabled nginx
# systemctl enable nginx
# systemctl is-enabled nginx

Selinux Management:

# getenforce
# vim /etc/selinux/config

Page Cloud Academy | +88013 1213 1212 | [Link]


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are
protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

# init 6
# getenforce

LAB: 03- SWAP & Memory management.

Swap is a space on a disk that is used when the amount of physical RAM memory is full.
When a Linux system runs out of RAM, inactive pages are moved from the RAM to the
swap space. Swap space can take the form of either a dedicated swap partition or a
swap file.

# vim /etc/fstab

Do # the below line

#/dev/mapper/rhel-swap none swap defaults 00

# init 6

Check the total memory Utilization in system as per process:

# ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb


",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'

Page Cloud Academy | +88013 1213 1212 | [Link]


LAB: 04- Nginx Installation and configuration and validation.

Nginx, stylized as NGIИX, is a web server that can also be used as a reverse proxy,
load balancer, mail proxy and HTTP cache. The software was created by Igor Sysoev
and publicly released in 2004. Nginx is free and open-source software, released
under the terms of the 2-clause BSD license.

# yum install nginx


# cd /etc/[Link].d/
# vim [Link]
[nginx]
name=nginx repo
baseurl=[Link]
gpgcheck=0
enabled=1
:x

# yum clean all


# yum repolist
# yum install nginx
# systemctl status nginx
# systemctl start nginx
# systemctl status nginx
# systemctl is-enabled nginx
# systemctl enable nginx
# systemctl is-enabled nginx

# firewall-cmd --permanent --add-port=80/tcp


# firewall-cmd --rel
# firewall-cmd --list-all
# cd /usr/share/nginx/
# vi [Link]
# echo '' > [Link]
# vi [Link]

LAB: 05- Nginx reverse proxy configuration and administration.

Follow the class

Page Cloud Academy | +88013 1213 1212 | [Link]


LAB: 06- Apache webserver installation and configuration and
validation.

The Apache HTTP Server or simply Apache, is free and open-source cross-platform web
server software developed and maintained by Apache Software Foundation. Apache is a
easy to learn and configure web server providing an ability to host websites mainly via
HTTP or HTTPS protocols. Under RHEL 8 / CentOS 8 system Apache webserver is know
under name httpd.

# yum install httpd


# systemctl enable httpd
# systemctl start httpd
# systemctl status httpd

# firewall-cmd --zone=public --permanent --add-service=http


# firewall-cmd --reload

By default the Apache web server will greet you with a default welcome [Link] disable
the default Apache welcome page insert
your [Link] into /var/www/html/ directory. For example:

# echo 'Welcome to Page Cloud Academy' > /var/www/html/[Link]

Go to web browser and http:<IP>

Page Cloud Academy | +88013 1213 1212 | [Link]


LAB: 07- Tomcat installation and configuration and validation.

Apache Tomcat is an open-source, lightweight, powerful and widely-used web server


developed and maintained by Apache Foundation. It is an implementation of the Java
Servlet, JavaServer Pages (JSP), Java Expression Language (EL) and Java
WebSocket technologies, and provides a pure Java HTTP server to run Java web-based
applications.

Tomcat Install and Configuration

# yum install java-1.8.0-openjdk-devel


# useradd -m -U -d /opt/tomcat -s /bin/false tomcat
# yum install tomcat
# yum install tomcat-webapps tomcat-admin-webapps
# yum install tomcat-docs-webapp tomcat-javadoc
# systemctl start tomcat
# systemctl restart tomcat
# systemctl enable tomcat
# systemctl status tomcat

# firewall-cmd --permanent --add-port=8080/tcp


# firewall-cmd –reload

# systemctl restart tomcat

CATALINA HOME: /usr/share/tomcat/webapps

[Link]

Page Cloud Academy | +88013 1213 1212 | [Link]


LAB: 08- HAproxy installation and configuration and validation.

HAProxy is a free, very fast and reliable solution offering high availability, load balancing,
and proxying for TCP and HTTP-based applications. It is particularly suited for very high
traffic web sites and powers quite a number of the world's most visited ones.

The balancing algorithms are used to decide which server at the backend each
connection is transferred to. Some of the useful options include the following:

Roundrobin: Each server is used in turns according to their weights. This is the
smoothest and fairest algorithm when the servers’ processing time remains equally
distributed. This algorithm is dynamic, which allows server weights to be adjusted on
the.

Leastconn: The server with the lowest number of connections is chosen. Round-robin is
performed between servers with the same load. Using this algorithm is recommended
with long sessions, such as LDAP, SQL, TSE, etc, but it is not very well suited for short
sessions such as HTTP.

First: The first server with available connection slots receives the connection. The
servers are chosen from the lowest numeric identifier to the highest, which defaults to
the server’s position on the farm. Once a server reaches its maxconn value, the next
server is used.

Source: The source IP address is hashed and divided by the total weight of the running
servers to designate which server will receive the request. This way the same client IP
address will always reach the same server while the servers stay the same.

Installation & Configuration

# yum info haproxy


# yum install gcc pcre-devel tar make -y
# wget [Link]
# tar xzvf [Link]

Page Cloud Academy | +88013 1213 1212 | [Link]


# cd haproxy-2.0.7

# make TARGET=linux-glibc
# make install

# mkdir -p /etc/haproxy
# mkdir -p /var/lib/haproxy
# touch /var/lib/haproxy/stats
# ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy

# cp ~/haproxy-2.0.7/examples/[Link] /etc/init.d/haproxy
# chmod 755 /etc/init.d/haproxy
# systemctl daemon-reload
# systemctl enable haproxy
# useradd -r haproxy
# haproxy –v

# firewall-cmd --permanent --add-service=http


# firewall-cmd --permanent --add-port=8181/tcp
# firewall-cmd --reload
# firewall-cmd --list-all

Config File & Directory

 /etc/haproxy

Configuration directory

 /etc/haproxy/[Link]

Configuration file

 /var/log/ [Link]

Log file

HAproxy Configuration:

# cd /etc/haproxy/

# vim [Link]

global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats timeout 30s
user haproxy
group haproxy
daemon

defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000

Page Cloud Academy | +88013 1213 1212 | [Link]


timeout server 50000
frontend http_front
bind *:80
stats uri /haproxy?stats
default_backend http_back

backend http_back
balance roundrobin
server webserver_1 [Link]:80 check
server webserver_2 [Link]:80 check

# systemctl restart haproxy


# systemctl status haproxy

Validation & GUI:

[Link]

Page Cloud Academy | +88013 1213 1212 | [Link]


API

The term web API generally refers to both sides of computer systems communicating
over a network: the API services offered by a server, as well as the API offered by the
client such as a web browser.

The server-side portion of the web API is a programmatic interface to a defined request-
response message system and is typically referred to as the Web Service. There are
several design models for web services, but the two most dominant are SOAP and REST.

What Is a SOAP API?


SOAP is a standard communication protocol system that permits processes using
different operating systems like Linux and Windows to communicate via HTTP and
its XML. SOAP based APIs are designed to create, recover, update and delete records like
accounts, passwords, leads, and custom objects.

These offers over twenty different kinds of calls that make it easy for the API developers
to maintain their accounts, perform accurate searches and much more. These can then
be used with all those languages that support web services.

SOAP APIs take the advantages of making web-based protocols such as HTTP and its
XML that are already operating the all operating systems that are why its developers can
easily manipulate web services and get responses without caring about language and
platforms at all.

Example:

A sample message exchange looks like the following.

Page Cloud Academy | +88013 1213 1212 | [Link]


The response from the service:

From this example we can see the message was sent over HTTP. SOAP is agnostic of the
underlying transport protocol and can be sent over almost any protocol such as HTTP,
SMTP, TCP, or JMS. As was already mentioned, the SOAP message itself must be XML-
formatted. As is normal for any XML document, there must be one root element: The
Envelope in this case.

This contains two required elements: The Header and the Body. The rest of the elements
in this message are described by the WSDL. The accompanying WSDL that defines the
above service looks like this (the details are not important, but the entire document is
shown here for completeness):

WSDL:

WSDL is Web Service Description Language, is an XML based definition language. It's
used for describing the functionality of a SOAP based web service. WSDL files are
central to testing SOAP-based services. SoapUI uses WSDL files to generate test
requests, assertions and mock services.

What WSDL file contains?

A WSDL document has a definitions element that contains the other five elements,
types, message, portType, binding and service. The following sections describe the
features of the generated client code.

What Is a REST API?


REST is basically an architectural style of the web services that work as a channel of
communication between different computers or systems on the internet. The term REST
API is something else.

Those application programming interfaces that are backed by the architectural style of
REST architectural system are called REST APIs. REST API compliant web services,
database systems, and computer systems permit requesting systems to get robust

Page Cloud Academy | +88013 1213 1212 | [Link]


access and redefine representations of web-based resources by deploying a predefined
set of stateless protocols and standard operations.

By these protocols and operations and redeploying the manageable and updatable
components without causing the effect on the system, REST API systems deliver fast
performance, reliability, and more progression.

Example:

A sample message exchange could contain as little as this -

As is already expected this message was sent over HTTP and used the GET verb.

Page Cloud Academy | +88013 1213 1212 | [Link]


Further note that the URI, which also had to be included in the SOAP request, but there
it had no meaning, here actually takes on a meaning. The body of the message is
significantly smaller, in this example there actually isn't one.

Differences:

 REST API has no official standard at all because it is an architectural style. SOAP
API, has an official standard because it is a protocol.
 REST APIs uses multiple standards like HTTP, JSON, URL, and XML while SOAP
APIs is largely based on HTTP and XML.
 As REST API deploys multiple standards, so it takes fewer resources and
bandwidth as compared to SOAP that uses XML for the creation of Payload and
results in the large sized file.
 The ways both APIs exposes the business logics are also different. REST API takes
advantage of URL exposure like @path("/WeatherService") while SOAP API use of
services interfaces like @WebService.
 SOAP API defines too many standards, and its implementer implements the
things in a standard way only. In the case of miscommunication from service, the
result will be the error. REST API, on the other hand, don't make emphasis on too
many standards and results in corrupt API in the end.
 REST API uses Web Application Description Language, and SOAP API used Web
Services Description language for describing the functionalities being offered by
web services.
 REST APIs are more convenient with JavaScript and can be implemented easily as
well. SOAP APIs are also convenient with JavaScript but don't support for greater
implementation.

DNS: The Domain Name System (DNS) is the phonebook of the Internet. Humans
access information online through domain names, like [Link] or [Link]. Web
browsers interact through Internet Protocol (IP) addresses. DNS translates domain
names to IP addresses so browsers can load Internet resources.

HTTP: hypertext transfer protocol, hypertext transfer protocol: the standard protocol
for transferring hypertext documents on the World Wide Web.

HTTPS: HTTPS (Hypertext Transfer Protocol Secure) is an internet communication


protocol that protects the integrity and confidentiality of data between the user's
computer and the site. Users expect a secure and private online experience when using
a website.

SSL: secure sockets layer, SSL Stands for secure sockets layer. Protocol for web
browsers and servers that allows for the authentication, encryption and decryption of
data sent over the Internet. ... Wildcard SSL certificates Type of certificate used to
secure multiple subdomains.

TLS: Transport Layer Security,Transport Layer Security (TLS) is the successor protocol
to SSL. TLS is an improved version of SSL. It works in much the same way as the SSL,
using encryption to protect the transfer of data and information. The two terms are often
used interchangeably in the industry although SSL is still widely used.

Page Cloud Academy | +88013 1213 1212 | [Link]


FTP: File transfer protocol, File transfer protocol (FTP) is a set of rules that computers
follow for the transferring of files from one system to another over the internet. It may
be used by a business to transfer files from one computer system to another, or
websites may use FTP to upload or download files from a website's server.

SFTP: SFTP (SSH File Transfer Protocol, also known as Secure FTP) is a popular method
for securely transferring files over remote systems. SFTP was designed as an extension
of the Secure Shell protocol (SSH) version 2.0 to enhance secure file transfer
capabilities.

SSH: Secure Shell (SSH) is a cryptographic network protocol for operating network
services securely over an unsecured network ,SSH is typically used to log into a remote
machine and execute commands, but it also supports tunneling, forwarding TCP ports
and X11 connections; it can transfer files using the associated SSH file transfer (SFTP) or
secure copy (SCP) protocols. SSH uses the client-server model.

Page Cloud Academy | +88013 1213 1212 | [Link]

You might also like