Решено. Apache2, не работают виртуальные хосты в chroot

Обсуждение настройки и работы сервисов, резервирования, сетевых настроек и вопросов безопасности ОС.

Модератор: SLEDopit

Ответить
UriyZenkov
Сообщения: 439
ОС: Devuan GNU/Linux
Контактная информация:

Решено. Apache2, не работают виртуальные хосты в chroot

Сообщение UriyZenkov »

Server version: Apache/2.4.48 (Debian) Server built: 2021-08-12T11:51:47

cat /etc/devuan_version
chimaera

mount:
udev on /home/chroot/dev devpts
on /home/chroot/dev/pts
/proc on /home/chroot/proc
/sys on /home/chroot/sys
/etc/apache2/sites-available/test.ru.conf
<VirtualHost *:80>

ServerName test.ru

ServerAlias www.test.ru

<Directory «/home/yura/www/test.ru»>

Options Indexes FollowSymLinks MultiViews

AllowOverride All

Order allow,deny

allow from all
a2ensite test.ru
service apache2 reload

На домашнем компе в /etc/hosts: <my_server_ip> test.ru

И после всего этого при переходе на test.ru открывается главная страница сервера, но в /home/yura/www/test.ru совершенно другой index.html.
Последний раз редактировалось UriyZenkov 03.11.2021 01:15, всего редактировалось 1 раз.
Спасибо сказали:
Аватара пользователя
Bizdelnick
Модератор
Сообщения: 20752
Статус: nulla salus bello
ОС: Debian GNU/Linux

Re: Apache2, не работают виртуальные хосты в chroot

Сообщение Bizdelnick »

DocumentRoot с Directory попутали?
Пишите правильно:
в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик
Спасибо сказали:
UriyZenkov
Сообщения: 439
ОС: Devuan GNU/Linux
Контактная информация:

Re: Apache2, не работают виртуальные хосты в chroot

Сообщение UriyZenkov »

Код: Выделить всё

<VirtualHost *:80>

 ServerName test.ru
 ServerAlias www.test.ru

 DocumentRoot /home/user/www/test.ru

 <Directory "/home/user/www/test.ru">
   Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

 </Directory>
</VirtualHost>
ls -a /home/user/www/test.ru
. .. .htaccess index.html
cat /home/user/www/test.ru/index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
test
</body>
</html>
cat /home/user/www/test.ru/.htaccess
DirectoryIndex index.html
tail -n 5 /var/log/apache2/error.log
[Mon Nov 01 11:54:10.643134 2021] [authz_core:error] [pid 125276] [client 127.0.0.1:46956] AH01630: client denied by server configuration: /home/user/www/test.ru/favicon.ico, referer: http://test.ru/
Последний раз редактировалось UriyZenkov 01.11.2021 15:27, всего редактировалось 1 раз.
Спасибо сказали:
Аватара пользователя
Bizdelnick
Модератор
Сообщения: 20752
Статус: nulla salus bello
ОС: Debian GNU/Linux

Re: Apache2, не работают виртуальные хосты в chroot

Сообщение Bizdelnick »

UriyZenkov писал:
01.11.2021 14:54
DocumentRoot /home/user/www/test.ru
UriyZenkov писал:
01.11.2021 14:54
<Directory "/home/user/test.ru">
Пишите правильно:
в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик
Спасибо сказали:
UriyZenkov
Сообщения: 439
ОС: Devuan GNU/Linux
Контактная информация:

Re: Apache2, не работают виртуальные хосты в chroot

Сообщение UriyZenkov »

исправил, перезагрузил ( service apache2 restart, открыл test.ru и в error.log та же ошибка.
Добавлено (15:33):
В /etc/hosts
127.0.0.1 localhost
В /etc/apache2/apache2.conf
ServerName localhost
Спасибо сказали:
UriyZenkov
Сообщения: 439
ОС: Devuan GNU/Linux
Контактная информация:

Re: Apache2, не работают виртуальные хосты в chroot

Сообщение UriyZenkov »

/home/chroot/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

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory "/var/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Redirect / https://google.com
</Directory>
# 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>
Добавлено (17:11):
/etc/apache2/apache2.conf
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
# /etc/apache2/
# |-- apache2.conf
# | `-- ports.conf
# |-- mods-enabled
# | |-- *.load
# | `-- *.conf
# |-- conf-enabled
# | `-- *.conf
# `-- sites-enabled
# `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
# together by including all remaining configuration files when starting up the
# web server.
#
# * ports.conf is always included from the main configuration file. It is
# supposed to determine listening ports for incoming connections which can be
# customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
# directories contain particular configuration snippets which manage modules,
# global configuration fragments, or virtual host configurations,
# respectively.
#
# They are activated by symlinking available configuration files from their
# respective *-available/ counterparts. These should be managed by using our
# helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
# their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
# the default configuration, apache2 needs to be started/stopped with
# /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
# work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# The directory where shm and other runtime files will be stored.
#

DefaultRuntimeDir ${APACHE_RUN_DIR}

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of
Спасибо сказали:
UriyZenkov
Сообщения: 439
ОС: Devuan GNU/Linux
Контактная информация:

Re: Apache2, не работают виртуальные хосты в chroot

Сообщение UriyZenkov »

Решение:

Код: Выделить всё

 <Directory "/home/yura/www/test.ru">
      Options -Indexes +FollowSymLinks +MultiViews
                AllowOverride All
                Require all granted
                Order Allow,Deny
                Allow from all
                Deny from none

 </Directory>
Помогли на кворке.
Спасибо сказали:
Ответить