not existing subdomain forward to next vhost
- Server: Debian 9
- Webserver: Apache2
My DNS A Record is *.domain.tld to my IP
I solve my apache vhosts by macro. If I type in a subdomain that does not exist, it will display the page of the next vhost file instead of a default page or an error.
Here is my 000-default.conf
ServerSignature Off
<Directory /home>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www
</VirtualHost>
<Macro Host $name $domain>
<VirtualHost $domain:80>
ServerName $domain
ServerAlias www.$domain
DocumentRoot /home/$name/html
AssignUserID $name $name
CustomLog /home/$name/logs/access.log vhost_combined
ErrorLog /home/$name/logs/error.log
<Directory /home/$name/html>
php_admin_value open_basedir /home/$name/html/:/var/lib/php/:/usr/share/php/:/usr/sbin/sendmail:/tmp
php_admin_value upload_tmp_dir /home/$name/html/tmp/
php_value upload_max_filesize 500M
php_value post_max_size 525M
php_value memory_limit 2000M
php_flag "output_buffering" Off
</Directory>
</VirtualHost>
</Macro>
<Macro SSLHost $name $domain>
<IfModule mod_ssl.c>
<VirtualHost $domain:443>
ServerName $domain
ServerAlias www.$domain
Alias /analytics /home/matomo/html
DocumentRoot /home/$name/html
AssignUserID $name $name
CustomLog /home/$name/logs/access.log vhost_combined
ErrorLog /home/$name/logs/error.log
<Directory /home/$name/html>
php_admin_value open_basedir /home/$name/html:/var/lib/php/:/usr/share/php/:/usr/sbin/sendmail:/tmp
php_admin_value upload_tmp_dir /home/$name/html/tmp
php_value upload_max_filesize 500M
php_value post_max_size 525M
php_value memory_limit 2000M
php_flag "output_buffering" Off
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias $domain
SSLCertificateFile /etc/letsencrypt/live/$domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$domain/privkey.pem
</VirtualHost>
</IfModule>
and as sample a macro vhost (001-sub.domain.tld.conf:
Use Host myXYuser sub.domain.tld
Use SSLHost myXYuser sub.domain.tld
So as example now the sub.domain.tld exists
When I type "xy.domain.tld" it display sub.domain.tld.. How can I avoid this?
Thanks in advance,
debian dns apache-http-server webserver domain
add a comment |
- Server: Debian 9
- Webserver: Apache2
My DNS A Record is *.domain.tld to my IP
I solve my apache vhosts by macro. If I type in a subdomain that does not exist, it will display the page of the next vhost file instead of a default page or an error.
Here is my 000-default.conf
ServerSignature Off
<Directory /home>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www
</VirtualHost>
<Macro Host $name $domain>
<VirtualHost $domain:80>
ServerName $domain
ServerAlias www.$domain
DocumentRoot /home/$name/html
AssignUserID $name $name
CustomLog /home/$name/logs/access.log vhost_combined
ErrorLog /home/$name/logs/error.log
<Directory /home/$name/html>
php_admin_value open_basedir /home/$name/html/:/var/lib/php/:/usr/share/php/:/usr/sbin/sendmail:/tmp
php_admin_value upload_tmp_dir /home/$name/html/tmp/
php_value upload_max_filesize 500M
php_value post_max_size 525M
php_value memory_limit 2000M
php_flag "output_buffering" Off
</Directory>
</VirtualHost>
</Macro>
<Macro SSLHost $name $domain>
<IfModule mod_ssl.c>
<VirtualHost $domain:443>
ServerName $domain
ServerAlias www.$domain
Alias /analytics /home/matomo/html
DocumentRoot /home/$name/html
AssignUserID $name $name
CustomLog /home/$name/logs/access.log vhost_combined
ErrorLog /home/$name/logs/error.log
<Directory /home/$name/html>
php_admin_value open_basedir /home/$name/html:/var/lib/php/:/usr/share/php/:/usr/sbin/sendmail:/tmp
php_admin_value upload_tmp_dir /home/$name/html/tmp
php_value upload_max_filesize 500M
php_value post_max_size 525M
php_value memory_limit 2000M
php_flag "output_buffering" Off
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias $domain
SSLCertificateFile /etc/letsencrypt/live/$domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$domain/privkey.pem
</VirtualHost>
</IfModule>
and as sample a macro vhost (001-sub.domain.tld.conf:
Use Host myXYuser sub.domain.tld
Use SSLHost myXYuser sub.domain.tld
So as example now the sub.domain.tld exists
When I type "xy.domain.tld" it display sub.domain.tld.. How can I avoid this?
Thanks in advance,
debian dns apache-http-server webserver domain
add a comment |
- Server: Debian 9
- Webserver: Apache2
My DNS A Record is *.domain.tld to my IP
I solve my apache vhosts by macro. If I type in a subdomain that does not exist, it will display the page of the next vhost file instead of a default page or an error.
Here is my 000-default.conf
ServerSignature Off
<Directory /home>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www
</VirtualHost>
<Macro Host $name $domain>
<VirtualHost $domain:80>
ServerName $domain
ServerAlias www.$domain
DocumentRoot /home/$name/html
AssignUserID $name $name
CustomLog /home/$name/logs/access.log vhost_combined
ErrorLog /home/$name/logs/error.log
<Directory /home/$name/html>
php_admin_value open_basedir /home/$name/html/:/var/lib/php/:/usr/share/php/:/usr/sbin/sendmail:/tmp
php_admin_value upload_tmp_dir /home/$name/html/tmp/
php_value upload_max_filesize 500M
php_value post_max_size 525M
php_value memory_limit 2000M
php_flag "output_buffering" Off
</Directory>
</VirtualHost>
</Macro>
<Macro SSLHost $name $domain>
<IfModule mod_ssl.c>
<VirtualHost $domain:443>
ServerName $domain
ServerAlias www.$domain
Alias /analytics /home/matomo/html
DocumentRoot /home/$name/html
AssignUserID $name $name
CustomLog /home/$name/logs/access.log vhost_combined
ErrorLog /home/$name/logs/error.log
<Directory /home/$name/html>
php_admin_value open_basedir /home/$name/html:/var/lib/php/:/usr/share/php/:/usr/sbin/sendmail:/tmp
php_admin_value upload_tmp_dir /home/$name/html/tmp
php_value upload_max_filesize 500M
php_value post_max_size 525M
php_value memory_limit 2000M
php_flag "output_buffering" Off
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias $domain
SSLCertificateFile /etc/letsencrypt/live/$domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$domain/privkey.pem
</VirtualHost>
</IfModule>
and as sample a macro vhost (001-sub.domain.tld.conf:
Use Host myXYuser sub.domain.tld
Use SSLHost myXYuser sub.domain.tld
So as example now the sub.domain.tld exists
When I type "xy.domain.tld" it display sub.domain.tld.. How can I avoid this?
Thanks in advance,
debian dns apache-http-server webserver domain
- Server: Debian 9
- Webserver: Apache2
My DNS A Record is *.domain.tld to my IP
I solve my apache vhosts by macro. If I type in a subdomain that does not exist, it will display the page of the next vhost file instead of a default page or an error.
Here is my 000-default.conf
ServerSignature Off
<Directory /home>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www
</VirtualHost>
<Macro Host $name $domain>
<VirtualHost $domain:80>
ServerName $domain
ServerAlias www.$domain
DocumentRoot /home/$name/html
AssignUserID $name $name
CustomLog /home/$name/logs/access.log vhost_combined
ErrorLog /home/$name/logs/error.log
<Directory /home/$name/html>
php_admin_value open_basedir /home/$name/html/:/var/lib/php/:/usr/share/php/:/usr/sbin/sendmail:/tmp
php_admin_value upload_tmp_dir /home/$name/html/tmp/
php_value upload_max_filesize 500M
php_value post_max_size 525M
php_value memory_limit 2000M
php_flag "output_buffering" Off
</Directory>
</VirtualHost>
</Macro>
<Macro SSLHost $name $domain>
<IfModule mod_ssl.c>
<VirtualHost $domain:443>
ServerName $domain
ServerAlias www.$domain
Alias /analytics /home/matomo/html
DocumentRoot /home/$name/html
AssignUserID $name $name
CustomLog /home/$name/logs/access.log vhost_combined
ErrorLog /home/$name/logs/error.log
<Directory /home/$name/html>
php_admin_value open_basedir /home/$name/html:/var/lib/php/:/usr/share/php/:/usr/sbin/sendmail:/tmp
php_admin_value upload_tmp_dir /home/$name/html/tmp
php_value upload_max_filesize 500M
php_value post_max_size 525M
php_value memory_limit 2000M
php_flag "output_buffering" Off
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias $domain
SSLCertificateFile /etc/letsencrypt/live/$domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$domain/privkey.pem
</VirtualHost>
</IfModule>
and as sample a macro vhost (001-sub.domain.tld.conf:
Use Host myXYuser sub.domain.tld
Use SSLHost myXYuser sub.domain.tld
So as example now the sub.domain.tld exists
When I type "xy.domain.tld" it display sub.domain.tld.. How can I avoid this?
Thanks in advance,
debian dns apache-http-server webserver domain
debian dns apache-http-server webserver domain
asked Jan 18 at 12:06
syntax412syntax412
82
82
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Apache 2.4 VirtualHost Examples
The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first .
Your first instance that has a ServerName directive will serve every invalid request (that specifies as ServerName).
1
Thanks. I did this modification: <VirtualHost *:80> ServerName example.com DocumentRoot /var/www </VirtualHost> but it does not works.. wrong requests doesn't go to var/www
– syntax412
Jan 18 at 15:14
Apache Default/Catch-All Virtual Host? might be relevant. Consider checking out ServerAlias. In addition it's not recommended to use the hostname for your VirtualHost directive. It might actually be interfering. See also Name based virtual host support.
– Seth
Jan 21 at 6:41
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395733%2fnot-existing-subdomain-forward-to-next-vhost%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Apache 2.4 VirtualHost Examples
The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first .
Your first instance that has a ServerName directive will serve every invalid request (that specifies as ServerName).
1
Thanks. I did this modification: <VirtualHost *:80> ServerName example.com DocumentRoot /var/www </VirtualHost> but it does not works.. wrong requests doesn't go to var/www
– syntax412
Jan 18 at 15:14
Apache Default/Catch-All Virtual Host? might be relevant. Consider checking out ServerAlias. In addition it's not recommended to use the hostname for your VirtualHost directive. It might actually be interfering. See also Name based virtual host support.
– Seth
Jan 21 at 6:41
add a comment |
Apache 2.4 VirtualHost Examples
The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first .
Your first instance that has a ServerName directive will serve every invalid request (that specifies as ServerName).
1
Thanks. I did this modification: <VirtualHost *:80> ServerName example.com DocumentRoot /var/www </VirtualHost> but it does not works.. wrong requests doesn't go to var/www
– syntax412
Jan 18 at 15:14
Apache Default/Catch-All Virtual Host? might be relevant. Consider checking out ServerAlias. In addition it's not recommended to use the hostname for your VirtualHost directive. It might actually be interfering. See also Name based virtual host support.
– Seth
Jan 21 at 6:41
add a comment |
Apache 2.4 VirtualHost Examples
The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first .
Your first instance that has a ServerName directive will serve every invalid request (that specifies as ServerName).
Apache 2.4 VirtualHost Examples
The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first .
Your first instance that has a ServerName directive will serve every invalid request (that specifies as ServerName).
answered Jan 18 at 13:08
SethSeth
6,38111128
6,38111128
1
Thanks. I did this modification: <VirtualHost *:80> ServerName example.com DocumentRoot /var/www </VirtualHost> but it does not works.. wrong requests doesn't go to var/www
– syntax412
Jan 18 at 15:14
Apache Default/Catch-All Virtual Host? might be relevant. Consider checking out ServerAlias. In addition it's not recommended to use the hostname for your VirtualHost directive. It might actually be interfering. See also Name based virtual host support.
– Seth
Jan 21 at 6:41
add a comment |
1
Thanks. I did this modification: <VirtualHost *:80> ServerName example.com DocumentRoot /var/www </VirtualHost> but it does not works.. wrong requests doesn't go to var/www
– syntax412
Jan 18 at 15:14
Apache Default/Catch-All Virtual Host? might be relevant. Consider checking out ServerAlias. In addition it's not recommended to use the hostname for your VirtualHost directive. It might actually be interfering. See also Name based virtual host support.
– Seth
Jan 21 at 6:41
1
1
Thanks. I did this modification: <VirtualHost *:80> ServerName example.com DocumentRoot /var/www </VirtualHost> but it does not works.. wrong requests doesn't go to var/www
– syntax412
Jan 18 at 15:14
Thanks. I did this modification: <VirtualHost *:80> ServerName example.com DocumentRoot /var/www </VirtualHost> but it does not works.. wrong requests doesn't go to var/www
– syntax412
Jan 18 at 15:14
Apache Default/Catch-All Virtual Host? might be relevant. Consider checking out ServerAlias. In addition it's not recommended to use the hostname for your VirtualHost directive. It might actually be interfering. See also Name based virtual host support.
– Seth
Jan 21 at 6:41
Apache Default/Catch-All Virtual Host? might be relevant. Consider checking out ServerAlias. In addition it's not recommended to use the hostname for your VirtualHost directive. It might actually be interfering. See also Name based virtual host support.
– Seth
Jan 21 at 6:41
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395733%2fnot-existing-subdomain-forward-to-next-vhost%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown