Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Offering Web Services

This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com


Objectives covered
208.1 Implementing a Web server - Basic Apache configuration
(w:4)

208.2 Apache configuration for HTTPS (w:3)

208.3 Implementing a proxy server - Squid as a caching proxy


(w:2)

208.4 Implementing Nginx as a web server and a reverse proxy


(w:2)

2
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
1 What is a Web server

This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com


Web server basics

4
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Basic HTTP session

5
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Client requests

6
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Server responses
Status code categories:

7
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Secure HTTPS session

8
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Linux web servers

9
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
2 The Apache Web server

This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com


Installing Apache web server

Ubuntu CentOS 11
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Manage Apache web server – apache2ctl utility

12
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Configure Apache web server

Location of config files for different distros

13
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Common Apache configuration directives

14
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Apache logs

Debian based:
/var/log/apache2/error.log

Error logs

RH based:
/var/log/httpd/error_log

Debian based:
/var/log/apache2/access.log

Access logs

RH based:
/var/log/httpd/access_log

15
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
User web hosting
Add the UserDir directive to the global configuration settings

To access files in the user’s public_html folder, you must


specify the username in the URL. For example, to access the
file /home/rich/public_html/test.html, you’d use the URL
http://localhost/~rich/test.html.

16
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Virtual web hosting
There are two ways to implement virtual web hosting in Apache:

Name-based virtual hosting IP-based virtual hosting


17
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Access restriction
Common Authentication loadable modules

18
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Access restriction
Using mod_auth method Using mod_access method

19
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Hosting Dynamic Web Applications
The Common Gateway Interface

20
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Hosting Dynamic Web Applications
The Programming modules

21
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server
Steps to creating HTTPS server

22
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server
Install SSL

To use SSL encryption on your Linux system, you’ll first need


to ensure that the mod_ssl Apache module is installed.

Besides SSL support for Apache, you’ll need the OpenSSL


software package installed. The OpenSSL package is a
popular open source software package that provides SSL
encryption capabilities for many network applications.

23
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server
Create an Encryption Key

24
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server
Create a Certificate Signing Request

25
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server
Sign the CSR

1. Create a CA for testing 2. Sign the CSR

26
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server

Install the Key and Certificate

27
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server

Configure Apache to Use SSL

28
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server
Additional SSL directives

29
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Creating a Secure Web Server
Connect to the HTTPS server with self-sign certificate

30
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
3 Using a proxy server

This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com


Squid

32
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Config Squid
Configuration file

Debian based Red Hat based

Basic Configuration settings

33
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Config Squid – Web cache

http_port
• The http_port directive defines the TCP port to which
clients must point their browsers
cache_dir
• The cache_dir directive defines where and how Squid will
store the cached web files

34
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Config Squid – Web access control
Define an ACL by using the acl directive Define rule to apply to ACL by using
http_access directive

ACL types

35
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Config Squid – Client authentication
1. Define authentication method by using the auth_param directive

2. Apply to ACL

36
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Config Squid – Configure client

37
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
4 The Nginx Server

This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com


Installing Nginx
Debian based Red Hat based

39
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
Configuring Nginx
Configuration file: /etc/nginx/nginx.conf

40
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com
THANKS!
ANY QUESTIONS?

41
This document is created by Nguyen Hoang Chi chi.nguyen.e4w@gmail.com

You might also like