Generally. The situation is as follows. There is a server that sits in the home network (192.h.h.h). It has an apache installed. Outward only 80 port is displayed. The external address of VVV.V. can also be reached to the machine at the address of the local subnet 10.L.L.L.

And there is a separate DNS server, where there is a redirect to the external address of VVB.V. from q.site.com and w.site.com

So, is it possible to make it so that requests from these addresses are processed as different virtual hosts in the Apache.

And another such question. Can the Apache find out what address the user came from if the request itself went to him through a pair of routers.

    4 answers 4

    Apache's documentation tells how to do it. And here are examples.

    For example:

    Listen 80 NameVirtualHost 10.0.0.3:80 <VirtualHost 10.0.0.3:80> ServerName q.site.com DocumentRoot /www/domain-80 </VirtualHost> <VirtualHost 10.0.0.3:80> ServerName q.site.com DocumentRoot /www/otherdomain-80 </VirtualHost> 

    And another such question. Can the Apache find out what address the user came from if the request itself went to him through a pair of routers.

    Yes.

    • The fact is that such settings do not work .. - stribog
     # portas.cfg NameVirtualHost *:80 ServerName example.ru # Без этой стоки выдает ошибку Listen 80 # ... # httpd.conf # пустой ... # apache2.conf # ... # sites-available/default <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName test.example.ru # Можно не писать, все равно обращение по ип будет приходить сюда. DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost> # sites-available/stribog <VirtualHost *:80> ServerAdmin stribog@example.ru ServerName stribog.example.ru DocumentRoot /home/stribog <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /home/stribog/error.log # Possible values include: debug, info, notice, warn, error, crit, alert, emerg. LogLevel debug CustomLog /home/stribog/access.log combined </VirtualHost> 

    So. What have we got? When any access to our host, configs from default will be used. Except for the address stribog.examlpe.com, stribog configs will be used when accessing it.

    Oddly enough, but the Internet did not find normal instructions. Selected configs by trial and error. In fact, I added a line ... the Apache rebooted ... I saw a mistake ... I randomly added a message ... I rebooted ...

    Yes, the main thing do not forget to include virtual hosts.

     a2ensite stribog 
    • I can’t approve my answer = ( - stribog
    • You need to wait two days, and a check mark will appear to accept your answer. - Nicolas Chabanovsky

    NameVirtualHost 10.0.0.3:80

     <VirtualHost 10.0.0.3:80> ServerName q.site.com DocumentRoot /www/domain-80 </VirtualHost> <VirtualHost 10.0.0.3:80> ServerName w.site.com DocumentRoot /www/otherdomain-80 </VirtualHost> 

      Apache: Adding virtual hosts