Local DNS - Redirect subdomains to different virtual hosts in apache2 The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsUsing 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?
University's motivation for having tenure-track positions
Who or what is the being for whom Being is a question for Heidegger?
"... to apply for a visa" or "... and applied for a visa"?
Why is the object placed in the middle of the sentence here?
Wall plug outlet change
Did the new image of black hole confirm the general theory of relativity?
How long does the line of fire that you can create as an action using the Investiture of Flame spell last?
Would an alien lifeform be able to achieve space travel if lacking in vision?
Finding the path in a graph from A to B then back to A with a minimum of shared edges
Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?
First use of “packing” as in carrying a gun
Four Colour Theorem
Why did all the guest students take carriages to the Yule Ball?
Take groceries in checked luggage
Typeface like Times New Roman but with "tied" percent sign
How to stretch delimiters to envolve matrices inside of a kbordermatrix?
How do you keep chess fun when your opponent constantly beats you?
Can smartphones with the same camera sensor have different image quality?
Do warforged have souls?
What information about me do stores get via my credit card?
Netflix Recommendations?
How can I define good in a religion that claims no moral authority?
How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?
Why can't devices on different VLANs, but on the same subnet, communicate?
Local DNS - Redirect subdomains to different virtual hosts in apache2
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election ResultsUsing 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 Apr 10 at 12:32
Ammy
New contributor
asked Apr 10 at 7:57
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
Apr 10 at 12:12
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
Apr 10 at 12:14
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
Apr 10 at 12:12
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
Apr 10 at 12:14
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
Apr 10 at 12:12
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
Apr 10 at 12:14
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 Apr 10 at 12:09
answered Apr 10 at 8:12
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
Apr 10 at 12:12
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
Apr 10 at 12:14
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
Apr 10 at 12:12
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
Apr 10 at 12:14
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
Apr 10 at 12:12
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
Apr 10 at 12:12
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
Apr 10 at 12:14
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
Apr 10 at 12:14
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