LeaYeh / webserver

MIT License
3 stars 0 forks source link

[FEAT] Add template of webserv config format #28

Closed LeaYeh closed 2 months ago

LeaYeh commented 3 months ago

Resolved #22

In the nginx_reference.conf, I noted how nginx config those requirements. And in webserv_all_features.conf, I based on the NGINX to design the prototype for our project.

Please go through the each item to check it matches the subject.

Depends on the subject, in the configuration file, you should be able to

LeaYeh commented 2 months ago

"The first server for a host:port will be the default for this host:port", for example:

In this configuration, the first server block (associated with example.com) is considered the default server because it’s the first one defined.

server {
    listen 80;
    server_name example.com;
    root /var/www/example.com;
}

server {
    listen 80;
    server_name other.com;
    root /var/www/other.com;
}

suppose an HTTP request comes in like this:

GET / HTTP/1.1
Host: unknown.com

In this request, the Host header is set to unknown.com. However, unknown.com is not explicitly defined in your server configuration. Since the server doesn’t have a specific match for unknown.com, it will be handled by the default server, which is the first one you defined (example.com).

So, the request will be processed by the default server block (example.com) and will serve content from the /var/www/example.com directory, even though the request was made for unknown.com.

In summary, if a request doesn’t match any explicitly defined server blocks, it will be handled by the default server.

yenthing commented 2 months ago

Got cha