Hosting Flashcards

1
Q

What is Apache in the context of web hosting?

A

Apache is one of the most established web servers used to host websites and web apps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two types of proxies used in hosting?

A

Forward proxy and reverse proxy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a forward proxy?

A

A server that sits between clients and the internet, forwarding requests from clients to web servers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a reverse proxy?

A

A server that sits in front of web servers, forwarding client requests to them and sending responses back to the client.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is NGINX commonly used for?

A

NGINX is used as a reverse proxy for load balancing, SSL termination, and caching.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the Apache Dockerfile do?

A

It creates a Docker image that uses Apache to serve an HTML file on port 80.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the content of the Apache Dockerfile?

A

It uses the httpd:latest base image, copies index.html to the default document root, and exposes port 80.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you build the Apache Docker image?

A

docker build -t apache-image .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you run the Apache container?

A

docker run –name apache-container -p 8081:80 apache-image

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why do we use port 8081 instead of port 80?

A

Because ports below 1024 are restricted; 8081 is an available unprivileged port.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you access a running Apache container’s shell?

A

docker exec -it apache-container /bin/bash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Where is Apache’s configuration file located in the container?

A

/usr/local/apache2/conf/httpd.conf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you copy Apache’s configuration file to your host machine?

A

docker cp apache-container:/usr/local/apache2/conf/httpd.conf .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the DocumentRoot directive in Apache?

A

It defines the directory from which Apache serves files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is HTTPS?

A

HTTPS is a secure version of HTTP using TLS to encrypt communication between client and server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does TLS stand for?

A

Transport Layer Security.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Why is TLS used in web hosting?

A

To secure communication by encrypting data between client and server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is required to set up TLS?

A

A valid certificate and private key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a self-signed certificate?

A

A certificate created and signed by the user instead of a Certificate Authority, used for testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do you generate a self-signed certificate using OpenSSL?

A

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -out selfsigned.crt -keyout private.key -subj “/C=UK/ST=Merseyside/L=Liverpool/O=MyOrg/CN=www.example.com”

21
Q

What does the -x509 flag do in OpenSSL?

A

It specifies that a self-signed certificate should be created.

22
Q

What does the -nodes flag do in OpenSSL?

A

It tells OpenSSL not to encrypt the private key.

23
Q

What does -newkey rsa:2048 do in OpenSSL?

A

It generates a new 2048-bit RSA private key.

24
Q

What is httpd-ssl.conf?

A

A custom Apache configuration file used to enable SSL on port 443.

25
What settings are in httpd-ssl.conf?
SSL engine on, certificate and key file paths, document root, and server name.
26
How do you update the Apache Dockerfile to enable HTTPS?
Add certificate and config files, enable SSL modules via sed, and include the SSL config.
27
What does the sed command do in the Apache Dockerfile?
It uncomments lines in httpd.conf to enable required modules like ssl_module.
28
What is the purpose of the socache_shmcb_module in Apache?
It enables session caching to improve SSL performance.
29
What does the RUN echo command do in the Dockerfile?
It appends the Include conf/extra/httpd-ssl.conf line to Apache’s httpd.conf.
30
What ports are exposed in the updated Dockerfile?
Port 80 for HTTP and port 443 for HTTPS.
31
How do you run the Apache container with HTTPS support?
docker run --name apache-ssl-container -p 8081:80 -p 8082:443 apache-ssl-image
32
Why does the browser show a warning with a self-signed certificate?
Because it isn’t issued by a trusted Certificate Authority, so the identity of the site can’t be verified.
33
What should you use for production instead of a self-signed certificate?
A certificate issued by a trusted Certificate Authority, like Let’s Encrypt.
34
What is a reverse proxy in NGINX?
A server that receives HTTP requests from clients and forwards them to backend servers like Apache.
35
What Docker command creates a shared network for containers?
docker network create web-net
36
Why is Docker networking important for NGINX and Apache integration?
It allows the NGINX container to resolve and communicate with the Apache container by name.
37
What are the contexts in an NGINX configuration file?
Main, events, http, server, and location.
38
What does the listen directive do in NGINX?
It specifies which port and protocol the server listens on.
39
What does server_name do in NGINX?
It defines the domain name(s) handled by that server block.
40
What does location do in NGINX?
It defines how requests for specific paths are handled.
41
What does proxy_pass do in NGINX?
It forwards incoming requests to a specified backend server.
42
What is the purpose of the upstream directive in NGINX?
It defines a group of backend servers for load balancing.
43
What does the sample NGINX config `proxy_pass http://apache-server;` do?
It forwards incoming HTTP requests to the Apache server.
44
What does removing /etc/nginx/conf.d/default.conf do in the Dockerfile?
It removes the default NGINX config to avoid conflicts with the custom config.
45
What does the custom NGINX Dockerfile do?
It builds a container using the official NGINX image with a custom reverse proxy configuration.
46
How do you build the custom NGINX image?
docker build -f Nginx.Dockerfile -t nginx-reverse-proxy .
47
How do you run Apache and NGINX containers together using a shared network?
docker run -d --name apache-container --network web-net apache-image && docker run -d --name nginx-proxy --network web-net -p 8083:80 nginx-reverse-proxy
48
What happens when you visit http://localhost:8083/?
You access the Apache website through the NGINX reverse proxy.