Comment fonctionnent ServerName et ServerAlias ?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment fonctionnent ServerName et ServerAlias ?

Message par ForumBot »

C'est le suivant part of a virtual host config that J'ai besoin de further clarification on:

```

# Admin email, Server Name (domain name), and any aliases
ServerAdmin [email protected]
ServerName 141.29.495.999
ServerAlias example.com
...

```

Ceci est et example config, similaire to what I currently have (Je ne have a domain name at le moment).

`` - Allow le suivant settings for tous HTTP requests made on port 80 to IPs that this server can be contacted on. Par exemple, si le server could be accessed on more than one IP, you could restrict this directive to juste one à la place of both.

`ServerName` - If le host part of le HTTP request matches this name, alors allow le request. Normally this would be a domain name that maps to an IP, mais dans ce cas le HTTP request host must match this IP.

`ServerAlias` - Alternate names accepted by le server.

The confusing part for me is, in le ci-dessus scenario, si I set `ServerAlias mytestname.com` et alors made an HTTP request to `mytestname.com`, there would have to be a DNS record pointing to le server's IP for this to work? In qui case, is ServerAlias juste basically EXTRA ServerName entries?

Say I had a DNS entry such that `foobar.com = 141.29.495.999` mais alors I had `ServerName = 141.29.495.999` et `ServerAlias` was empty, would that mean that bien que foobar.com gets resolved to le right IP, parce que there is no reference to accept foobar.com in `ServerName` ou `ServerAlias`?

Or something. Man Je suis confused.
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Comment fonctionnent ServerName et ServerAlias ?

Message par ForumBot »

Think of it like this:

DNS is le phone directory/yellow pages. When someone wants to call votre phone, they can look up votre name et get votre phone number et call that phone. DNS does le même mais for computers - quand someone wants to allez dans `www.example.com` they ask DNS for le IP address et alors they can contact le computer that has that IP address. That is what **resolve** means. Resolving an IP address has nothing at tous to do avec Apache; it is strictly a DNS question.

The `ServerName` et `ServerAlias` is more like a company's internal phone list. Your webserver is le switchboard; it will accept tous incoming connections to le server. Then le client/caller will tell them what name they're looking for, et it will look in le Apache configuration for how to handle that name.

If le name n'est pas listed as a ServerName/ServerAlias in le apache configuration, apache will toujours give them le premier VirtualHost listed. Or, si il y a no VirtualHost at all, it will give le même content no matter what hostname is given in le request.

## ETA: So, step by step for a normal connection:

- You type `http://www.example.com` into votre browser.

- Your computer asks its DNS resolver qui IP address it should use quand it wants to talk to `www.example.com`.

- Your computer connects to that IP address, et says that it wants to talk to `www.example.com` (c'est le `Host:`header in HTTP).

- The webserver looks at its configuration to figure out what to do avec a request for content depuis `www.example.com`. Any one of le suivant may happen:

- `www.example.com` is listed as a `ServerName` ou `ServerAlias` for a `VirtualHost` - si so, alors it will use le configuration for that VirtualHost to deliver le content.

- The server ne have tout VirtualHosts at tous - si so, alors it will use le configuration in its httpd.conf to deliver le content.

- The server has VirtualHosts mais `www.example.com` n'est pas listed in tout of them - si so, le premier Virtualhost in le list will be used to deliver le content.
Répondre

Revenir à « Active Directory & Entra »