Web Programming Website And Web Server Programming 3 — Questions and Answers
Question 1: In Nginx configuration, which block defines settings for a specific domain or IP address?
- server (Correct answer)
- location
- upstream
- http
Correct answer: server
The 'server' block in Nginx corresponds to a virtual host and defines how requests for a particular domain or port are handled.
Question 2: What is the purpose of CORS headers on a web server?
- Allow or restrict cross-origin browser requests to the server's resources (Correct answer)
- Compress response payloads
- Cache static assets on the CDN
- Authenticate API tokens
Correct answer: Allow or restrict cross-origin browser requests to the server's resources
CORS (Cross-Origin Resource Sharing) headers like Access-Control-Allow-Origin tell browsers which external origins may access the server's resources.
Question 3: Which Python web framework follows the 'batteries included' philosophy and includes an ORM, admin panel, and authentication out of the box?
- Django (Correct answer)
- Flask
- FastAPI
- Tornado
Correct answer: Django
Django ships with a full ORM, automatic admin interface, form handling, and authentication system by default.
Question 4: What does SSL/TLS termination at a load balancer or reverse proxy mean?
- The proxy decrypts HTTPS traffic and forwards plain HTTP to backend servers (Correct answer)
- The proxy blocks all encrypted connections
- Backend servers handle all certificate validation
- SSL certificates are stored in the browser
Correct answer: The proxy decrypts HTTPS traffic and forwards plain HTTP to backend servers
SSL termination offloads the decryption work to the edge proxy, allowing simpler HTTP communication between the proxy and internal servers.
Question 5: In web server configuration, what does a 'virtual host' allow you to do?
- Host multiple websites on a single server using different domain names (Correct answer)
- Run multiple operating systems simultaneously
- Virtualize the network interface for load balancing
- Create isolated file system containers
Correct answer: Host multiple websites on a single server using different domain names
Virtual hosting lets one physical server respond to requests for multiple domains by routing based on the Host header or IP address.
Question 6: Which PHP superglobal array contains data submitted via an HTML form using the POST method?
- $_POST (Correct answer)
- $_GET
- $_REQUEST
- $_SERVER
Correct answer: $_POST
$_POST contains key-value pairs of variables submitted in the HTTP request body when the form method is POST.
Question 7: What is the role of a reverse proxy in a web server architecture?
- Sits in front of backend servers and forwards client requests to them (Correct answer)
- Caches DNS responses for faster resolution
- Converts HTTP to FTP for file transfers
- Manages database connection pools
Correct answer: Sits in front of backend servers and forwards client requests to them
A reverse proxy intercepts incoming client requests, applies rules (load balancing, caching, SSL), and routes them to the appropriate backend server.
In Nginx configuration, which block defines settings for a specific domain or IP address?