Local DNS - Redirect subdomains to different virtual hosts in apache2 The 2019 Stack Overflow Developer Survey Results Are InUsing FACLs to restrict default group but allow othersLinux basic web server setup and access“403 Forbidden - You don't have permission to access / on this server” - apache2 localhost on Linux Mint 17What exactly does logrotate do to apache log files? (apache 2.4 - ubuntu 14.04)apache configuration problems, last vhost loaded becomes wildcard domainExchange apache2 for nginx problemWebdav won't connect: 405 Method Not AllowedMy mediawiki page displayed index of/ after updating to apache 2.4.23How to redirect all requests for localhost:483 to localhost:80 with dnsmasqHow do I get DNSMasq to serve up DNS to Windows hosts without a domain?
Why can't devices on different VLANs, but on the same subnet, communicate?
How to translate "being like"?
How do I free up internal storage if I don't have any apps downloaded?
What does もの mean in this sentence?
Are spiders unable to hurt humans, especially very small spiders?
Falsification in Math vs Science
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
A female thief is not sold to make restitution -- so what happens instead?
Why doesn't UInt have a toDouble()?
writing variables above the numbers in tikz picture
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
How to type a long/em dash `—`
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
Output the Arecibo Message
How can I define good in a religion that claims no moral authority?
A word that means fill it to the required quantity
What is preventing me from simply constructing a hash that's lower than the current target?
Why is the maximum length of OpenWrt’s root password 8 characters?
Mathematics of imaging the black hole
Loose spokes after only a few rides
Pokemon Turn Based battle (Python)
Cooking pasta in a water boiler
Accepted by European university, rejected by all American ones I applied to? Possible reasons?
How to add class in ko template in magento2
Local DNS - Redirect subdomains to different virtual hosts in apache2
The 2019 Stack Overflow Developer Survey Results Are InUsing FACLs to restrict default group but allow othersLinux basic web server setup and access“403 Forbidden - You don't have permission to access / on this server” - apache2 localhost on Linux Mint 17What exactly does logrotate do to apache log files? (apache 2.4 - ubuntu 14.04)apache configuration problems, last vhost loaded becomes wildcard domainExchange apache2 for nginx problemWebdav won't connect: 405 Method Not AllowedMy mediawiki page displayed index of/ after updating to apache 2.4.23How to redirect all requests for localhost:483 to localhost:80 with dnsmasqHow do I get DNSMasq to serve up DNS to Windows hosts without a domain?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've set up three virtual hosts in apache 2.4 with the following entrys:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName www.xx.de
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/sh/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName sh.xx.de
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/nc/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName n.xx.de
</VirtualHost>
The access works from the internet as well as from local network. But if I'm in local network, I want to redirect querys to the local IP not to the external IP. The DNS is on the same device as the apache is. I've already tried using dnsmasq to resolve xx.de
with the local IP 192.168.0.55
. This works, if I'm using xx.de/sh/
for example. But sh.xx.de
doesn't work.
apache-httpd dnsmasq
New contributor
add a comment |
I've set up three virtual hosts in apache 2.4 with the following entrys:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName www.xx.de
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/sh/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName sh.xx.de
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/nc/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName n.xx.de
</VirtualHost>
The access works from the internet as well as from local network. But if I'm in local network, I want to redirect querys to the local IP not to the external IP. The DNS is on the same device as the apache is. I've already tried using dnsmasq to resolve xx.de
with the local IP 192.168.0.55
. This works, if I'm using xx.de/sh/
for example. But sh.xx.de
doesn't work.
apache-httpd dnsmasq
New contributor
add a comment |
I've set up three virtual hosts in apache 2.4 with the following entrys:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName www.xx.de
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/sh/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName sh.xx.de
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/nc/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName n.xx.de
</VirtualHost>
The access works from the internet as well as from local network. But if I'm in local network, I want to redirect querys to the local IP not to the external IP. The DNS is on the same device as the apache is. I've already tried using dnsmasq to resolve xx.de
with the local IP 192.168.0.55
. This works, if I'm using xx.de/sh/
for example. But sh.xx.de
doesn't work.
apache-httpd dnsmasq
New contributor
I've set up three virtual hosts in apache 2.4 with the following entrys:
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName www.xx.de
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/sh/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName sh.xx.de
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/nc/
ErrorLog $APACHE_LOG_DIR/error.log
CustomLog $APACHE_LOG_DIR/access.log combined
ServerName n.xx.de
</VirtualHost>
The access works from the internet as well as from local network. But if I'm in local network, I want to redirect querys to the local IP not to the external IP. The DNS is on the same device as the apache is. I've already tried using dnsmasq to resolve xx.de
with the local IP 192.168.0.55
. This works, if I'm using xx.de/sh/
for example. But sh.xx.de
doesn't work.
apache-httpd dnsmasq
apache-httpd dnsmasq
New contributor
New contributor
edited yesterday
Ammy
New contributor
asked yesterday
AmmyAmmy
11
11
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
DNS only maps IP addresses to Hostnames and vice versa, not to a URL
A URL is made up of 3* parts, lets take http://example.com/foo:
- a Scheme e.g. http:
- a Host e.g. example.com
- a Path e.g. /foo
So when the browser on your computer requests http://example.com/foo the DNS will convert example.com to the IP address. The computer will then use the IP address to connect to the remote machine on the default Scheme port (80 for http).
Once connected it will make a HTTP request (e.g GET /foo) and as part of the request it will include the HTTP Host Header. This header tells the HTTP server which hostname the browser looked up in the DNS. This then allows the HTTP server to map the request to the correct Virtual Host.
It sounds like you need to set up 3 virtual hosts on the machine with the IP address 192.168.0.55.
- one for a.xx.com
- one for b.xx.com
- a default virtual host (to cover the raw IP address 192.168.0.55) that hosts the actual /aaaa and /bbbb directories
The first 2 should redirect to the correct path hosted by the 3rd.
*There can be more parts (e.g. user/password, port and query), but this is enough for this example
Thank You! But I've already set up the three virtual hosts. It is already working from the internal network and also from external. But the traffic is always over the internet. I wanted to prevent this by using the dns. So I've got two use cases: 1: I'm outside of my network: a.xx.com leads to xx.com/aaaa, whereby xx.com is resolved with the external ip address --> already working 2: I'm connected with my network: a.xx.com leads to 192.168.0.55/aaaa --> not working yet. The main problem is the usage of the subdomain. "xx.com/aaaa" works currently with the dnsmasq entry, but not "a.xx.com"
– Ammy
yesterday
That is very different to what the question asks. Please edit the question to match this description. And include the details of how you have configured Apache as that is the important part, not the DNS setup
– hardillb
yesterday
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
);
);
Ammy is a new contributor. Be nice, and check out our Code of Conduct.
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%2funix.stackexchange.com%2fquestions%2f511615%2flocal-dns-redirect-subdomains-to-different-virtual-hosts-in-apache2%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
DNS only maps IP addresses to Hostnames and vice versa, not to a URL
A URL is made up of 3* parts, lets take http://example.com/foo:
- a Scheme e.g. http:
- a Host e.g. example.com
- a Path e.g. /foo
So when the browser on your computer requests http://example.com/foo the DNS will convert example.com to the IP address. The computer will then use the IP address to connect to the remote machine on the default Scheme port (80 for http).
Once connected it will make a HTTP request (e.g GET /foo) and as part of the request it will include the HTTP Host Header. This header tells the HTTP server which hostname the browser looked up in the DNS. This then allows the HTTP server to map the request to the correct Virtual Host.
It sounds like you need to set up 3 virtual hosts on the machine with the IP address 192.168.0.55.
- one for a.xx.com
- one for b.xx.com
- a default virtual host (to cover the raw IP address 192.168.0.55) that hosts the actual /aaaa and /bbbb directories
The first 2 should redirect to the correct path hosted by the 3rd.
*There can be more parts (e.g. user/password, port and query), but this is enough for this example
Thank You! But I've already set up the three virtual hosts. It is already working from the internal network and also from external. But the traffic is always over the internet. I wanted to prevent this by using the dns. So I've got two use cases: 1: I'm outside of my network: a.xx.com leads to xx.com/aaaa, whereby xx.com is resolved with the external ip address --> already working 2: I'm connected with my network: a.xx.com leads to 192.168.0.55/aaaa --> not working yet. The main problem is the usage of the subdomain. "xx.com/aaaa" works currently with the dnsmasq entry, but not "a.xx.com"
– Ammy
yesterday
That is very different to what the question asks. Please edit the question to match this description. And include the details of how you have configured Apache as that is the important part, not the DNS setup
– hardillb
yesterday
add a comment |
DNS only maps IP addresses to Hostnames and vice versa, not to a URL
A URL is made up of 3* parts, lets take http://example.com/foo:
- a Scheme e.g. http:
- a Host e.g. example.com
- a Path e.g. /foo
So when the browser on your computer requests http://example.com/foo the DNS will convert example.com to the IP address. The computer will then use the IP address to connect to the remote machine on the default Scheme port (80 for http).
Once connected it will make a HTTP request (e.g GET /foo) and as part of the request it will include the HTTP Host Header. This header tells the HTTP server which hostname the browser looked up in the DNS. This then allows the HTTP server to map the request to the correct Virtual Host.
It sounds like you need to set up 3 virtual hosts on the machine with the IP address 192.168.0.55.
- one for a.xx.com
- one for b.xx.com
- a default virtual host (to cover the raw IP address 192.168.0.55) that hosts the actual /aaaa and /bbbb directories
The first 2 should redirect to the correct path hosted by the 3rd.
*There can be more parts (e.g. user/password, port and query), but this is enough for this example
Thank You! But I've already set up the three virtual hosts. It is already working from the internal network and also from external. But the traffic is always over the internet. I wanted to prevent this by using the dns. So I've got two use cases: 1: I'm outside of my network: a.xx.com leads to xx.com/aaaa, whereby xx.com is resolved with the external ip address --> already working 2: I'm connected with my network: a.xx.com leads to 192.168.0.55/aaaa --> not working yet. The main problem is the usage of the subdomain. "xx.com/aaaa" works currently with the dnsmasq entry, but not "a.xx.com"
– Ammy
yesterday
That is very different to what the question asks. Please edit the question to match this description. And include the details of how you have configured Apache as that is the important part, not the DNS setup
– hardillb
yesterday
add a comment |
DNS only maps IP addresses to Hostnames and vice versa, not to a URL
A URL is made up of 3* parts, lets take http://example.com/foo:
- a Scheme e.g. http:
- a Host e.g. example.com
- a Path e.g. /foo
So when the browser on your computer requests http://example.com/foo the DNS will convert example.com to the IP address. The computer will then use the IP address to connect to the remote machine on the default Scheme port (80 for http).
Once connected it will make a HTTP request (e.g GET /foo) and as part of the request it will include the HTTP Host Header. This header tells the HTTP server which hostname the browser looked up in the DNS. This then allows the HTTP server to map the request to the correct Virtual Host.
It sounds like you need to set up 3 virtual hosts on the machine with the IP address 192.168.0.55.
- one for a.xx.com
- one for b.xx.com
- a default virtual host (to cover the raw IP address 192.168.0.55) that hosts the actual /aaaa and /bbbb directories
The first 2 should redirect to the correct path hosted by the 3rd.
*There can be more parts (e.g. user/password, port and query), but this is enough for this example
DNS only maps IP addresses to Hostnames and vice versa, not to a URL
A URL is made up of 3* parts, lets take http://example.com/foo:
- a Scheme e.g. http:
- a Host e.g. example.com
- a Path e.g. /foo
So when the browser on your computer requests http://example.com/foo the DNS will convert example.com to the IP address. The computer will then use the IP address to connect to the remote machine on the default Scheme port (80 for http).
Once connected it will make a HTTP request (e.g GET /foo) and as part of the request it will include the HTTP Host Header. This header tells the HTTP server which hostname the browser looked up in the DNS. This then allows the HTTP server to map the request to the correct Virtual Host.
It sounds like you need to set up 3 virtual hosts on the machine with the IP address 192.168.0.55.
- one for a.xx.com
- one for b.xx.com
- a default virtual host (to cover the raw IP address 192.168.0.55) that hosts the actual /aaaa and /bbbb directories
The first 2 should redirect to the correct path hosted by the 3rd.
*There can be more parts (e.g. user/password, port and query), but this is enough for this example
edited yesterday
answered yesterday
hardillbhardillb
1588
1588
Thank You! But I've already set up the three virtual hosts. It is already working from the internal network and also from external. But the traffic is always over the internet. I wanted to prevent this by using the dns. So I've got two use cases: 1: I'm outside of my network: a.xx.com leads to xx.com/aaaa, whereby xx.com is resolved with the external ip address --> already working 2: I'm connected with my network: a.xx.com leads to 192.168.0.55/aaaa --> not working yet. The main problem is the usage of the subdomain. "xx.com/aaaa" works currently with the dnsmasq entry, but not "a.xx.com"
– Ammy
yesterday
That is very different to what the question asks. Please edit the question to match this description. And include the details of how you have configured Apache as that is the important part, not the DNS setup
– hardillb
yesterday
add a comment |
Thank You! But I've already set up the three virtual hosts. It is already working from the internal network and also from external. But the traffic is always over the internet. I wanted to prevent this by using the dns. So I've got two use cases: 1: I'm outside of my network: a.xx.com leads to xx.com/aaaa, whereby xx.com is resolved with the external ip address --> already working 2: I'm connected with my network: a.xx.com leads to 192.168.0.55/aaaa --> not working yet. The main problem is the usage of the subdomain. "xx.com/aaaa" works currently with the dnsmasq entry, but not "a.xx.com"
– Ammy
yesterday
That is very different to what the question asks. Please edit the question to match this description. And include the details of how you have configured Apache as that is the important part, not the DNS setup
– hardillb
yesterday
Thank You! But I've already set up the three virtual hosts. It is already working from the internal network and also from external. But the traffic is always over the internet. I wanted to prevent this by using the dns. So I've got two use cases: 1: I'm outside of my network: a.xx.com leads to xx.com/aaaa, whereby xx.com is resolved with the external ip address --> already working 2: I'm connected with my network: a.xx.com leads to 192.168.0.55/aaaa --> not working yet. The main problem is the usage of the subdomain. "xx.com/aaaa" works currently with the dnsmasq entry, but not "a.xx.com"
– Ammy
yesterday
Thank You! But I've already set up the three virtual hosts. It is already working from the internal network and also from external. But the traffic is always over the internet. I wanted to prevent this by using the dns. So I've got two use cases: 1: I'm outside of my network: a.xx.com leads to xx.com/aaaa, whereby xx.com is resolved with the external ip address --> already working 2: I'm connected with my network: a.xx.com leads to 192.168.0.55/aaaa --> not working yet. The main problem is the usage of the subdomain. "xx.com/aaaa" works currently with the dnsmasq entry, but not "a.xx.com"
– Ammy
yesterday
That is very different to what the question asks. Please edit the question to match this description. And include the details of how you have configured Apache as that is the important part, not the DNS setup
– hardillb
yesterday
That is very different to what the question asks. Please edit the question to match this description. And include the details of how you have configured Apache as that is the important part, not the DNS setup
– hardillb
yesterday
add a comment |
Ammy is a new contributor. Be nice, and check out our Code of Conduct.
Ammy is a new contributor. Be nice, and check out our Code of Conduct.
Ammy is a new contributor. Be nice, and check out our Code of Conduct.
Ammy is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f511615%2flocal-dns-redirect-subdomains-to-different-virtual-hosts-in-apache2%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
-apache-httpd, dnsmasq