---
title: "HTTP request methods; web server and virtual hosting"
subject: "Internet and Intranet"
chapter: 4
key: "semester_8/internet_and_intranet:http-methods-config-virtual-hosting"
source: https://www.bctengineer.com/q/semester_8/internet_and_intranet/http-methods-config-virtual-hosting
site: BCT Engineering
---

# HTTP request methods; web server and virtual hosting

Internet and Intranet · Chapter 4: HTTP and the Web Services

- Asked in: 2070 Bhadra, 4+7 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/internet_and_intranet/http-methods-config-virtual-hosting
- Whole chapter: https://www.bctengineer.com/md/semester_8/internet_and_intranet/chapter-4

## Question

Explain the request methods of HTTP? Write the major steps while configuring web server and the types of web hosting (Virtual Hosting) from your web server.

## Short answer

Key HTTP methods: GET (retrieve), POST (submit), HEAD (headers). Web server config: set IP, install, define ServerName/DocumentRoot, open port, restart. Virtual hosting: IP-based, port-based, name-based (uses Host header).

## Answer

#### HTTP request methods

The first line of an HTTP request is: `METHOD URL VERSION`. The main methods:

| Method | Purpose |
|---|---|
| GET | Retrieve the resource named by the URL. Data in the query string; no body. Safe and idempotent. |
| POST | Send data (form input, file upload) in the body for the server to process. |
| HEAD | Like GET but the server returns only headers, not the object. Used to check size/modification time. |
| PUT | Upload/replace the resource at the URL. |
| DELETE | Remove the resource at the URL. |
| OPTIONS | Ask which methods the server supports. |
| TRACE | Echo the request back, for diagnostics. |
| CONNECT | Make a tunnel through a proxy (used for HTTPS). |

Example: `GET /index.html HTTP/1.1` with header `Host: www.example.com`.

#### Major steps to configure a web server (Apache on Linux)

1. Assign a static IP address and set a host name; set up DNS (A record) for the site.
2. Install the software: `yum install httpd` or `apt install apache2`.
3. Edit the main configuration (`httpd.conf` / `apache2.conf`): `Listen 80`, `ServerName`, `DocumentRoot /var/www/html`, `DirectoryIndex index.html`, access rules in `<Directory>`.
4. Put the web pages in the document root and set file permissions.
5. Open port 80 (443 for HTTPS) in the firewall.
6. Test syntax (`apachectl configtest`), start and enable the service (`systemctl enable --now httpd`).
7. Browse to `http://server-ip/` and check the logs in `/var/log/httpd/`.

#### Types of virtual hosting

Virtual hosting lets one server host several sites.

- **IP-based:** each site has its own IP address; `<VirtualHost 192.168.1.10:80>`.
- **Port-based:** same IP, different ports; `<VirtualHost *:8080>`.
- **Name-based:** same IP and port, selected by the HTTP `Host:` header.

```apache
<VirtualHost *:80>
    ServerName www.a.com
    DocumentRoot /var/www/a
</VirtualHost>
<VirtualHost *:80>
    ServerName www.b.com
    DocumentRoot /var/www/b
</VirtualHost>
```

Name-based hosting is the most economical because only one IP address is needed. IP-based hosting is required when each site needs its own SSL certificate on old clients.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which pairing is correct?
   A. HEAD returns the object body only
   B. POST sends data in the body for the server to process; HEAD returns only headers
   C. GET sends data in the body
   D. PUT retrieves a resource
   Answer: B. POST carries form data in the body, HEAD returns headers without the object, and GET retrieves a resource. (Key point: GET vs POST vs HEAD)

2. Which method is used to make a tunnel through a proxy, for HTTPS?
   A. TRACE
   B. OPTIONS
   C. CONNECT
   D. PUT
   Answer: C. CONNECT sets up a tunnel via a proxy; TRACE echoes the request and OPTIONS lists supported methods. (Key point: PUT, DELETE, CONNECT)

3. Which sequence matches the major steps of configuring Apache?
   A. Install, edit config (Listen, ServerName, DocumentRoot), place pages, open firewall port, test syntax and start, browse
   B. Browse, install, edit config
   C. Start service, then install, then edit
   D. Edit DNS only
   Answer: A. Install the software, set the main configuration, add pages, open port 80/443, check syntax and start the service, then test in a browser. (Key point: Web server config steps)

## Related in Internet and Intranet

- [Virtual hosting types; name-based steps](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Avirtual-hosting-types-named-steps) — Internet and Intranet, chapter 4, asked 2×
- [Virtual hosting and HTTP connections](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Avirtual-hosting-http-connections) — Internet and Intranet, chapter 4
- [HTTP working, methods, virtual hosting](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Ahttp-works-methods-virtual-hosting) — Internet and Intranet, chapter 4
- [Short note: Web virtual hosting](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Anote-virtual-hosting) — Internet and Intranet, chapter 4, asked 2×

## Related in other subjects

- [HTTP request served by server](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Ahttp-request-served) — Computer Networks and Security, chapter 6
- [Web and file server communication](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aweb-file-server-communication) — Computer Networks and Security, chapter 6
- [Short note: Web server](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Aweb-server-note) — Computer Networks and Security, chapter 6
- [Steps of virtual (unit) load method](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Aunit-load-method-steps) — Theory of Structures I, chapter 3, asked 4×
