Как создть субдомен третьего подуровня в Apache2?

Здравствуйте.
Ситуация такая. Есть сервер с выделенным IP. (Условно 213.хх.хх.хх) На нем стоит ОС Linux (Ubuntu 16.04). Под ней установлен apache2. В сервисе freenom зарегестрировал доменное имя второго уровня. (Условно mysite.tk). Все работает нормально. хочу сделать домен третьего уровня. cloud.mysite.tk, например. В сервисе freenom нашел опцию Register glue records и вписал туда " cloud". А дальше решительно не понимаю как это сделать. Примерно день гуглил и совсем запутался .__.

Есть файл /etc/hosts
127.0.0.1       localhost
127.0.1.1       mysite.tk
127.0.1.1       cloud.mysite.tk

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


файл /etc/apache2/apache2.conf
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>
<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf


Файл /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
<IfModule ssl_module>
        Listen 443
</IfModule>
<IfModule mod_gnutls.c>
        Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


Файл /etc/apache2/sites-available/000-default.conf
VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        #Redirect http://  https://
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


Файл /etc/apache2/sites-available/something.conf

Alias /something "/var/www/something/"
<Directory /var/www/something/>
    Options +FollowSymlinks
    AllowOverride All
    <IfModule mod_dav.c>
        Dav off
    </IfModule>
    SetEnv HOME /var/www/something
    SetEnv HTTP_HOME /var/www/something
</Directory>

Как оно работает: захожу на сайт mysite.tk. Там у меня страничка и на ней ссылки всякие. Можно перейти mysite.tk/something и это будет работать.
Как я хочу. захожу на сайт mysite.tk. Там у меня страничка и на ней ссылки всякие. Можно перейти something.mysite.tk и это будет работать.
Из гугления я понял, что нужно оставить только один большой хост, который будет слушать 80 порт и ловить запросы. Дальше смотреть заголовки http (что для меня звучит странно) и перенаправлять на нужный домен. С серверами DNS, как я понял особо возиться не нужно, потому что все настраивается во freenom.
  • Вопрос задан
  • 358 просмотров
Пригласить эксперта
Ответы на вопрос 1
Sanasol
@Sanasol Куратор тега Веб-разработка
нельзя просто так взять и загуглить ошибку
домены .tk вообще нормально не продают.

они все работают через iframe или еще как-нибудь через жопу. Хотя это обычно к бесплатным .tk относится.

А чтоб их продавали не помню даже.

Короче возьмите для начала нормальный домен, который работает как обычно.

Причем здесь ваш Есть файл /etc/hosts даже боюсь спрашивать.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы