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;








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.










share|improve this question









New contributor




Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    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.










    share|improve this question









    New contributor




    Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      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.










      share|improve this question









      New contributor




      Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      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






      share|improve this question









      New contributor




      Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday







      Ammy













      New contributor




      Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked yesterday









      AmmyAmmy

      11




      11




      New contributor




      Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Ammy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes


















          0














          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:



          1. a Scheme e.g. http:

          2. a Host e.g. example.com

          3. 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.



          1. one for a.xx.com

          2. one for b.xx.com

          3. 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






          share|improve this answer

























          • 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












          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.









          draft saved

          draft discarded


















          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









          0














          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:



          1. a Scheme e.g. http:

          2. a Host e.g. example.com

          3. 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.



          1. one for a.xx.com

          2. one for b.xx.com

          3. 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






          share|improve this answer

























          • 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
















          0














          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:



          1. a Scheme e.g. http:

          2. a Host e.g. example.com

          3. 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.



          1. one for a.xx.com

          2. one for b.xx.com

          3. 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






          share|improve this answer

























          • 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














          0












          0








          0







          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:



          1. a Scheme e.g. http:

          2. a Host e.g. example.com

          3. 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.



          1. one for a.xx.com

          2. one for b.xx.com

          3. 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






          share|improve this answer















          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:



          1. a Scheme e.g. http:

          2. a Host e.g. example.com

          3. 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.



          1. one for a.xx.com

          2. one for b.xx.com

          3. 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







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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


















          • 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











          Ammy is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          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.




          draft saved


          draft discarded














          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





















































          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

          Popular posts from this blog

          Frič See also Navigation menuinternal link

          Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant

          fontconfig warning: “/etc/fonts/fonts.conf”, line 100: unknown “element blank” The 2019 Stack Overflow Developer Survey Results Are In“tar: unrecognized option --warning” during 'apt-get install'How to fix Fontconfig errorHow do I figure out which font file is chosen for a system generic font alias?Why are some apt-get-installed fonts being ignored by fc-list, xfontsel, etc?Reload settings in /etc/fonts/conf.dTaking 30 seconds longer to boot after upgrade from jessie to stretchHow to match multiple font names with a single <match> element?Adding a custom font to fontconfigRemoving fonts from fontconfig <match> resultsBroken fonts after upgrading Firefox ESR to latest Firefox